{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# iTorch / Torch7 implementation\n",
    "\n",
    "\n",
    "**Gm = d** in lua/torch for LuaJIT. \n",
    "\n",
    "\n",
    "## Prerequisites\n",
    "\n",
    "You need to install `torch` and (if you want to run this notebook) `iTorch`. Works for me on Ubuntu 16.04 and MacOS 10.11. Not gonna say the Mac installation is easy though. Everything was very smooth on Ubuntu.\n",
    "\n",
    "- [Getting started with Torch](http://torch.ch/docs/getting-started.html)\n",
    "- [iTorch Requirements](https://github.com/facebook/iTorch#requirements)\n",
    "- [Torch cheatsheet](https://github.com/torch/torch7/wiki/Cheatsheet)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "Plot = require 'itorch.Plot'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "-- Implements MATLAB's convmtx.\n",
    "function convmtx (h, n)\n",
    "    local m = h:size()[1] - 1\n",
    "    local c = torch.Tensor(n, n+m):fill(0)\n",
    "    for i = 1, n do\n",
    "        c[{ i, {i, i+m} }] = h\n",
    "    end\n",
    "    return c\n",
    "end"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       " 1 -1  0  0  0  0\n",
       " 0  1 -1  0  0  0\n",
       " 0  0  1 -1  0  0\n",
       " 0  0  0  1 -1  0\n",
       " 0  0  0  0  1 -1\n",
       "[torch.DoubleTensor of size 5x6]\n",
       "\n"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "convmtx(torch.Tensor({1, -1}), 5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "-- Implements bruges's ricker.\n",
    "function ricker (f, length, dt)\n",
    "    -- Defaults.\n",
    "    f = f or 25\n",
    "    length = length or 0.128\n",
    "    dt = dt or 0.001\n",
    "\n",
    "    -- Time basis.\n",
    "    local t = torch.range(0, length, dt) - length/2\n",
    "    \n",
    "    -- Amplitudes.\n",
    "    local x = 1 - 2 * math.pi * f^2 * torch.pow(t, 2)\n",
    "    local y = torch.exp(-math.pi^2 * f^2 * torch.pow(t, 2))\n",
    "    local a = torch.cmul(x, y)\n",
    "\n",
    "    return t, a\n",
    "end"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Construct the model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "--                         VP    RHO\n",
    "imp = torch.ones(51, 1) * 2550 * 2650\n",
    "imp[{{11, 15}, {}}] =     2700 * 2750   \n",
    "imp[{{16, 27}, {}}] =     2400 * 2450\n",
    "imp[{{28, 35}, {}}] =     2800 * 3000"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script type=\"text/javascript\">\n",
       "$(function() {\n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\"){\n",
       "  window._bokeh_onload_callbacks = [];\n",
       "    }\n",
       "    function load_lib(url, callback){\n",
       "  window._bokeh_onload_callbacks.push(callback);\n",
       "  if (window._bokeh_is_loading){\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", new Date());\n",
       "      return null;\n",
       "  }\n",
       "  console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", new Date());\n",
       "  window._bokeh_is_loading = true;\n",
       "  var s = document.createElement('script');\n",
       "  s.src = url;\n",
       "  s.async = true;\n",
       "  s.onreadystatechange = s.onload = function(){\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh-0.7.0.min.css\");\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback){callback()});\n",
       "  };\n",
       "  s.onerror = function(){\n",
       "      console.warn(\"failed to load library \" + url);\n",
       "  };\n",
       "  document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "\n",
       "    bokehjs_url = \"https://cdn.pydata.org/bokeh-0.7.0.min.js\"\n",
       "\n",
       "    var elt = document.getElementById(\"1abaa17f-bd72-4876-c83c-1f031df8990d\");\n",
       "    if(elt==null) {\n",
       "  console.log(\"Bokeh: ERROR: autoload.js configured with elementid '1abaa17f-bd72-4876-c83c-1f031df8990d'\"\n",
       "        + \"but no matching script tag was found. \")\n",
       "  return false;\n",
       "    }\n",
       "\n",
       "    if(typeof(Bokeh) !== \"undefined\") {\n",
       "  console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "  var modelid = \"525beeef-1526-4bb9-cbcf-5fed4d9e2200\";\n",
       "  var modeltype = \"Plot\";\n",
       "  var all_models = [{\"id\":\"fb8d1727-b786-45ce-c531-9c54b5609220\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,7425000,7425000,7425000,7425000,7425000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,8400000,8400000,8400000,8400000,8400000,8400000,8400000,8400000,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"fb8d1727-b786-45ce-c531-9c54b5609220\",\"doc\":null,\"tags\":[]}},{\"id\":\"598729a1-0cf7-497a-c946-bb2b6c2bb0b4\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"598729a1-0cf7-497a-c946-bb2b6c2bb0b4\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"294bc1d6-012f-4c1b-ccc7-8ff65da8cfb9\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"294bc1d6-012f-4c1b-ccc7-8ff65da8cfb9\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"8065d0d8-e099-4afe-ca1c-cd2fa32b7fc2\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Line\",\"id\":\"294bc1d6-012f-4c1b-ccc7-8ff65da8cfb9\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"fb8d1727-b786-45ce-c531-9c54b5609220\"},\"glyph\":{\"type\":\"Line\",\"id\":\"598729a1-0cf7-497a-c946-bb2b6c2bb0b4\"},\"selection_glyph\":null,\"id\":\"8065d0d8-e099-4afe-ca1c-cd2fa32b7fc2\",\"tags\":[]}},{\"id\":\"b8bff12f-b404-43d6-c3ca-4404aedee39e\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"fb8d1727-b786-45ce-c531-9c54b5609220\"}}],\"id\":\"b8bff12f-b404-43d6-c3ca-4404aedee39e\",\"tags\":[],\"doc\":null}},{\"id\":\"90ac4a97-417d-4903-c98b-ed9a675d4918\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"fb8d1727-b786-45ce-c531-9c54b5609220\"}}],\"id\":\"90ac4a97-417d-4903-c98b-ed9a675d4918\",\"tags\":[],\"doc\":null}},{\"id\":\"50ab886e-2ffc-4562-c531-022fe52b2fa8\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"50ab886e-2ffc-4562-c531-022fe52b2fa8\",\"geometries\":[],\"doc\":null}},{\"id\":\"22748664-18c5-491a-c983-aa6519a2cf3d\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"22748664-18c5-491a-c983-aa6519a2cf3d\",\"tags\":[],\"doc\":null}},{\"id\":\"dfc5d210-21c2-4941-c9e8-e315d3e43f11\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"dfc5d210-21c2-4941-c9e8-e315d3e43f11\",\"tags\":[],\"doc\":null}},{\"id\":\"dbcc3eaa-b727-47b6-c720-42663355dce0\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"22748664-18c5-491a-c983-aa6519a2cf3d\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"dfc5d210-21c2-4941-c9e8-e315d3e43f11\"},\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"dbcc3eaa-b727-47b6-c720-42663355dce0\",\"doc\":null,\"tags\":[]}},{\"id\":\"5009ef23-82c9-4a61-ca83-74682f17fda2\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"dfc5d210-21c2-4941-c9e8-e315d3e43f11\"},\"id\":\"5009ef23-82c9-4a61-ca83-74682f17fda2\",\"doc\":null,\"tags\":[]}},{\"id\":\"cb31dc76-94d6-465b-c6f7-be2f9280a00e\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"cb31dc76-94d6-465b-c6f7-be2f9280a00e\",\"tags\":[],\"doc\":null}},{\"id\":\"2ce6d563-645b-437e-c3e5-955c0880629e\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"2ce6d563-645b-437e-c3e5-955c0880629e\",\"tags\":[],\"doc\":null}},{\"id\":\"ae9bdc2a-8636-481f-c89f-c93e65dd2be2\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"cb31dc76-94d6-465b-c6f7-be2f9280a00e\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"2ce6d563-645b-437e-c3e5-955c0880629e\"},\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"ae9bdc2a-8636-481f-c89f-c93e65dd2be2\",\"doc\":null,\"tags\":[]}},{\"id\":\"6ea307e2-93aa-4cdd-cc53-0fe234bdd645\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"2ce6d563-645b-437e-c3e5-955c0880629e\"},\"id\":\"6ea307e2-93aa-4cdd-cc53-0fe234bdd645\",\"doc\":null,\"tags\":[]}},{\"id\":\"16ca4d4e-69df-4fa1-cf2a-9b4b1287e209\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"16ca4d4e-69df-4fa1-cf2a-9b4b1287e209\",\"doc\":null,\"tags\":[]}},{\"id\":\"bc15cc70-ce9e-41f7-c15e-cf43818825f6\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"bc15cc70-ce9e-41f7-c15e-cf43818825f6\",\"doc\":null,\"tags\":[]}},{\"id\":\"f58a716c-0919-4ed1-ce81-4532f5591c71\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"f58a716c-0919-4ed1-ce81-4532f5591c71\",\"tags\":[],\"doc\":null}},{\"id\":\"7d0e3034-00f9-433f-c303-8ee9f15f43eb\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"7d0e3034-00f9-433f-c303-8ee9f15f43eb\",\"tags\":[],\"doc\":null}},{\"id\":\"3f6751a2-733b-4934-c931-1d1d86374e94\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"3f6751a2-733b-4934-c931-1d1d86374e94\",\"tags\":[],\"doc\":null}},{\"id\":\"916b9db1-7745-489e-c89f-1f690cc20823\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"916b9db1-7745-489e-c89f-1f690cc20823\",\"tags\":[],\"doc\":null}},{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"b8bff12f-b404-43d6-c3ca-4404aedee39e\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"50ab886e-2ffc-4562-c531-022fe52b2fa8\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"dbcc3eaa-b727-47b6-c720-42663355dce0\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"8065d0d8-e099-4afe-ca1c-cd2fa32b7fc2\"},{\"type\":\"LinearAxis\",\"id\":\"dbcc3eaa-b727-47b6-c720-42663355dce0\"},{\"type\":\"Grid\",\"id\":\"5009ef23-82c9-4a61-ca83-74682f17fda2\"},{\"type\":\"LinearAxis\",\"id\":\"ae9bdc2a-8636-481f-c89f-c93e65dd2be2\"},{\"type\":\"Grid\",\"id\":\"6ea307e2-93aa-4cdd-cc53-0fe234bdd645\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"16ca4d4e-69df-4fa1-cf2a-9b4b1287e209\"},{\"type\":\"WheelZoomTool\",\"id\":\"bc15cc70-ce9e-41f7-c15e-cf43818825f6\"},{\"type\":\"BoxZoomTool\",\"id\":\"f58a716c-0919-4ed1-ce81-4532f5591c71\"},{\"type\":\"PreviewSaveTool\",\"id\":\"7d0e3034-00f9-433f-c303-8ee9f15f43eb\"},{\"type\":\"ResizeTool\",\"id\":\"3f6751a2-733b-4934-c931-1d1d86374e94\"},{\"type\":\"ResetTool\",\"id\":\"916b9db1-7745-489e-c89f-1f690cc20823\"}],\"doc\":null,\"right\":[],\"title\":\"Impedance\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"ae9bdc2a-8636-481f-c89f-c93e65dd2be2\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"90ac4a97-417d-4903-c98b-ed9a675d4918\"},\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "  Bokeh.load_models(all_models);\n",
       "  var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "  $(\"#1abaa17f-bd72-4876-c83c-1f031df8990d\").html(''); // clear any previous plot in window_id\n",
       "  var view = new model.default_view({model: model, el: \"#1abaa17f-bd72-4876-c83c-1f031df8990d\"});\n",
       "    } else {\n",
       "  load_lib(bokehjs_url, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", new Date())\n",
       "      var modelid = \"525beeef-1526-4bb9-cbcf-5fed4d9e2200\";\n",
       "      var modeltype = \"Plot\";\n",
       "      var all_models = [{\"id\":\"fb8d1727-b786-45ce-c531-9c54b5609220\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,7425000,7425000,7425000,7425000,7425000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,5880000,8400000,8400000,8400000,8400000,8400000,8400000,8400000,8400000,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500,6757500],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"fb8d1727-b786-45ce-c531-9c54b5609220\",\"doc\":null,\"tags\":[]}},{\"id\":\"598729a1-0cf7-497a-c946-bb2b6c2bb0b4\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"598729a1-0cf7-497a-c946-bb2b6c2bb0b4\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"294bc1d6-012f-4c1b-ccc7-8ff65da8cfb9\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"294bc1d6-012f-4c1b-ccc7-8ff65da8cfb9\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"8065d0d8-e099-4afe-ca1c-cd2fa32b7fc2\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Line\",\"id\":\"294bc1d6-012f-4c1b-ccc7-8ff65da8cfb9\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"fb8d1727-b786-45ce-c531-9c54b5609220\"},\"glyph\":{\"type\":\"Line\",\"id\":\"598729a1-0cf7-497a-c946-bb2b6c2bb0b4\"},\"selection_glyph\":null,\"id\":\"8065d0d8-e099-4afe-ca1c-cd2fa32b7fc2\",\"tags\":[]}},{\"id\":\"b8bff12f-b404-43d6-c3ca-4404aedee39e\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"fb8d1727-b786-45ce-c531-9c54b5609220\"}}],\"id\":\"b8bff12f-b404-43d6-c3ca-4404aedee39e\",\"tags\":[],\"doc\":null}},{\"id\":\"90ac4a97-417d-4903-c98b-ed9a675d4918\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"fb8d1727-b786-45ce-c531-9c54b5609220\"}}],\"id\":\"90ac4a97-417d-4903-c98b-ed9a675d4918\",\"tags\":[],\"doc\":null}},{\"id\":\"50ab886e-2ffc-4562-c531-022fe52b2fa8\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"50ab886e-2ffc-4562-c531-022fe52b2fa8\",\"geometries\":[],\"doc\":null}},{\"id\":\"22748664-18c5-491a-c983-aa6519a2cf3d\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"22748664-18c5-491a-c983-aa6519a2cf3d\",\"tags\":[],\"doc\":null}},{\"id\":\"dfc5d210-21c2-4941-c9e8-e315d3e43f11\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"dfc5d210-21c2-4941-c9e8-e315d3e43f11\",\"tags\":[],\"doc\":null}},{\"id\":\"dbcc3eaa-b727-47b6-c720-42663355dce0\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"22748664-18c5-491a-c983-aa6519a2cf3d\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"dfc5d210-21c2-4941-c9e8-e315d3e43f11\"},\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"dbcc3eaa-b727-47b6-c720-42663355dce0\",\"doc\":null,\"tags\":[]}},{\"id\":\"5009ef23-82c9-4a61-ca83-74682f17fda2\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"dfc5d210-21c2-4941-c9e8-e315d3e43f11\"},\"id\":\"5009ef23-82c9-4a61-ca83-74682f17fda2\",\"doc\":null,\"tags\":[]}},{\"id\":\"cb31dc76-94d6-465b-c6f7-be2f9280a00e\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"cb31dc76-94d6-465b-c6f7-be2f9280a00e\",\"tags\":[],\"doc\":null}},{\"id\":\"2ce6d563-645b-437e-c3e5-955c0880629e\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"2ce6d563-645b-437e-c3e5-955c0880629e\",\"tags\":[],\"doc\":null}},{\"id\":\"ae9bdc2a-8636-481f-c89f-c93e65dd2be2\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"cb31dc76-94d6-465b-c6f7-be2f9280a00e\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"2ce6d563-645b-437e-c3e5-955c0880629e\"},\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"ae9bdc2a-8636-481f-c89f-c93e65dd2be2\",\"doc\":null,\"tags\":[]}},{\"id\":\"6ea307e2-93aa-4cdd-cc53-0fe234bdd645\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"2ce6d563-645b-437e-c3e5-955c0880629e\"},\"id\":\"6ea307e2-93aa-4cdd-cc53-0fe234bdd645\",\"doc\":null,\"tags\":[]}},{\"id\":\"16ca4d4e-69df-4fa1-cf2a-9b4b1287e209\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"16ca4d4e-69df-4fa1-cf2a-9b4b1287e209\",\"doc\":null,\"tags\":[]}},{\"id\":\"bc15cc70-ce9e-41f7-c15e-cf43818825f6\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"bc15cc70-ce9e-41f7-c15e-cf43818825f6\",\"doc\":null,\"tags\":[]}},{\"id\":\"f58a716c-0919-4ed1-ce81-4532f5591c71\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"f58a716c-0919-4ed1-ce81-4532f5591c71\",\"tags\":[],\"doc\":null}},{\"id\":\"7d0e3034-00f9-433f-c303-8ee9f15f43eb\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"7d0e3034-00f9-433f-c303-8ee9f15f43eb\",\"tags\":[],\"doc\":null}},{\"id\":\"3f6751a2-733b-4934-c931-1d1d86374e94\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"3f6751a2-733b-4934-c931-1d1d86374e94\",\"tags\":[],\"doc\":null}},{\"id\":\"916b9db1-7745-489e-c89f-1f690cc20823\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"916b9db1-7745-489e-c89f-1f690cc20823\",\"tags\":[],\"doc\":null}},{\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"b8bff12f-b404-43d6-c3ca-4404aedee39e\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"50ab886e-2ffc-4562-c531-022fe52b2fa8\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"dbcc3eaa-b727-47b6-c720-42663355dce0\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"8065d0d8-e099-4afe-ca1c-cd2fa32b7fc2\"},{\"type\":\"LinearAxis\",\"id\":\"dbcc3eaa-b727-47b6-c720-42663355dce0\"},{\"type\":\"Grid\",\"id\":\"5009ef23-82c9-4a61-ca83-74682f17fda2\"},{\"type\":\"LinearAxis\",\"id\":\"ae9bdc2a-8636-481f-c89f-c93e65dd2be2\"},{\"type\":\"Grid\",\"id\":\"6ea307e2-93aa-4cdd-cc53-0fe234bdd645\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"16ca4d4e-69df-4fa1-cf2a-9b4b1287e209\"},{\"type\":\"WheelZoomTool\",\"id\":\"bc15cc70-ce9e-41f7-c15e-cf43818825f6\"},{\"type\":\"BoxZoomTool\",\"id\":\"f58a716c-0919-4ed1-ce81-4532f5591c71\"},{\"type\":\"PreviewSaveTool\",\"id\":\"7d0e3034-00f9-433f-c303-8ee9f15f43eb\"},{\"type\":\"ResizeTool\",\"id\":\"3f6751a2-733b-4934-c931-1d1d86374e94\"},{\"type\":\"ResetTool\",\"id\":\"916b9db1-7745-489e-c89f-1f690cc20823\"}],\"doc\":null,\"right\":[],\"title\":\"Impedance\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"ae9bdc2a-8636-481f-c89f-c93e65dd2be2\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"90ac4a97-417d-4903-c98b-ed9a675d4918\"},\"id\":\"525beeef-1526-4bb9-cbcf-5fed4d9e2200\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "      Bokeh.load_models(all_models);\n",
       "      var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "      $(\"#1abaa17f-bd72-4876-c83c-1f031df8990d\").html(''); // clear any previous plot in window_id\n",
       "      var view = new model.default_view({model: model, el: \"#1abaa17f-bd72-4876-c83c-1f031df8990d\"});\n",
       "  });\n",
       "    }\n",
       "});\n",
       "</script>\n",
       "<div class=\"plotdiv\" id=\"1abaa17f-bd72-4876-c83c-1f031df8990d\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = torch.range(1, imp:size(1))\n",
    "plot = Plot():line(x, imp[{{},1}])\n",
    "             :title('Impedance')\n",
    "             :draw()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "numerator = imp[{{2, imp:size(1)}}] - imp[{{1, imp:size(1) - 1}}]\n",
    "denominator = imp[{{2, imp:size(1)}}] + imp[{{1, imp:size(1) - 1}}]\n",
    "m = torch.cdiv(numerator, denominator)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script type=\"text/javascript\">\n",
       "$(function() {\n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\"){\n",
       "  window._bokeh_onload_callbacks = [];\n",
       "    }\n",
       "    function load_lib(url, callback){\n",
       "  window._bokeh_onload_callbacks.push(callback);\n",
       "  if (window._bokeh_is_loading){\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", new Date());\n",
       "      return null;\n",
       "  }\n",
       "  console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", new Date());\n",
       "  window._bokeh_is_loading = true;\n",
       "  var s = document.createElement('script');\n",
       "  s.src = url;\n",
       "  s.async = true;\n",
       "  s.onreadystatechange = s.onload = function(){\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh-0.7.0.min.css\");\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback){callback()});\n",
       "  };\n",
       "  s.onerror = function(){\n",
       "      console.warn(\"failed to load library \" + url);\n",
       "  };\n",
       "  document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "\n",
       "    bokehjs_url = \"https://cdn.pydata.org/bokeh-0.7.0.min.js\"\n",
       "\n",
       "    var elt = document.getElementById(\"38bd9b0b-8d2c-432c-c33c-6353b5ddd497\");\n",
       "    if(elt==null) {\n",
       "  console.log(\"Bokeh: ERROR: autoload.js configured with elementid '38bd9b0b-8d2c-432c-c33c-6353b5ddd497'\"\n",
       "        + \"but no matching script tag was found. \")\n",
       "  return false;\n",
       "    }\n",
       "\n",
       "    if(typeof(Bokeh) !== \"undefined\") {\n",
       "  console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "  var modelid = \"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\";\n",
       "  var modeltype = \"Plot\";\n",
       "  var all_models = [{\"id\":\"9ad64c8d-0dc1-490d-c9da-0dd82bac1e91\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[0,0,0,0,0,0,0,0,0,0.047065044949762,0,0,0,0,-0.11612175873732,0,0,0,0,0,0,0,0,0,0,0,0.17647058823529,0,0,0,0,0,0,0,-0.10836219693221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"9ad64c8d-0dc1-490d-c9da-0dd82bac1e91\",\"doc\":null,\"tags\":[]}},{\"id\":\"88fe02b4-c305-4443-c4bc-51a48e8ab53c\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"blue\"},\"line_color\":{\"value\":\"blue\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"88fe02b4-c305-4443-c4bc-51a48e8ab53c\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"3de3aa81-2bc2-4514-c55b-552a597be5ee\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"blue\"},\"line_color\":{\"value\":\"blue\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"3de3aa81-2bc2-4514-c55b-552a597be5ee\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"30478146-1415-43bc-c354-2f11b7f63741\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Line\",\"id\":\"3de3aa81-2bc2-4514-c55b-552a597be5ee\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"9ad64c8d-0dc1-490d-c9da-0dd82bac1e91\"},\"glyph\":{\"type\":\"Line\",\"id\":\"88fe02b4-c305-4443-c4bc-51a48e8ab53c\"},\"selection_glyph\":null,\"id\":\"30478146-1415-43bc-c354-2f11b7f63741\",\"tags\":[]}},{\"id\":\"67fedde7-77f3-4be4-cbee-f8d7e302e1f3\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"9ad64c8d-0dc1-490d-c9da-0dd82bac1e91\"}}],\"id\":\"67fedde7-77f3-4be4-cbee-f8d7e302e1f3\",\"tags\":[],\"doc\":null}},{\"id\":\"bf1c741c-5060-4927-c9b9-07391de6e8a4\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"9ad64c8d-0dc1-490d-c9da-0dd82bac1e91\"}}],\"id\":\"bf1c741c-5060-4927-c9b9-07391de6e8a4\",\"tags\":[],\"doc\":null}},{\"id\":\"e4375cef-c895-46d0-c6a9-fab205519e72\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"e4375cef-c895-46d0-c6a9-fab205519e72\",\"geometries\":[],\"doc\":null}},{\"id\":\"648b2e60-e405-4c40-cc5b-fff61141078a\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"648b2e60-e405-4c40-cc5b-fff61141078a\",\"tags\":[],\"doc\":null}},{\"id\":\"489e075e-014c-4ef5-ce93-ac111bcdfad3\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"489e075e-014c-4ef5-ce93-ac111bcdfad3\",\"tags\":[],\"doc\":null}},{\"id\":\"4323d333-fe4b-47ae-c720-624cf01f3eae\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"648b2e60-e405-4c40-cc5b-fff61141078a\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"489e075e-014c-4ef5-ce93-ac111bcdfad3\"},\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"4323d333-fe4b-47ae-c720-624cf01f3eae\",\"doc\":null,\"tags\":[]}},{\"id\":\"1aa638fb-0aeb-4e45-cebe-45eea8d8a6e4\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"489e075e-014c-4ef5-ce93-ac111bcdfad3\"},\"id\":\"1aa638fb-0aeb-4e45-cebe-45eea8d8a6e4\",\"doc\":null,\"tags\":[]}},{\"id\":\"a5b6de1d-d2b3-4e39-ce5e-d76a30234d47\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"a5b6de1d-d2b3-4e39-ce5e-d76a30234d47\",\"tags\":[],\"doc\":null}},{\"id\":\"d8769ff3-60c1-4be2-cbef-3376017c54e6\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"d8769ff3-60c1-4be2-cbef-3376017c54e6\",\"tags\":[],\"doc\":null}},{\"id\":\"5cff97a7-73c3-432a-c325-b8d3f3c8984a\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"a5b6de1d-d2b3-4e39-ce5e-d76a30234d47\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d8769ff3-60c1-4be2-cbef-3376017c54e6\"},\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"5cff97a7-73c3-432a-c325-b8d3f3c8984a\",\"doc\":null,\"tags\":[]}},{\"id\":\"8fece7b3-34f4-4a7d-ca00-df339eec392a\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d8769ff3-60c1-4be2-cbef-3376017c54e6\"},\"id\":\"8fece7b3-34f4-4a7d-ca00-df339eec392a\",\"doc\":null,\"tags\":[]}},{\"id\":\"51b3bdeb-9054-46ac-c68b-ae4a6f851315\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"51b3bdeb-9054-46ac-c68b-ae4a6f851315\",\"doc\":null,\"tags\":[]}},{\"id\":\"4e5f4750-9a88-4fca-cf9f-cd4ce3b7a203\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"4e5f4750-9a88-4fca-cf9f-cd4ce3b7a203\",\"doc\":null,\"tags\":[]}},{\"id\":\"49fd7e0a-99e4-42c9-c230-569e198fd904\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"49fd7e0a-99e4-42c9-c230-569e198fd904\",\"tags\":[],\"doc\":null}},{\"id\":\"71c762a4-7339-4c46-cc34-a9cde1830045\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"71c762a4-7339-4c46-cc34-a9cde1830045\",\"tags\":[],\"doc\":null}},{\"id\":\"c743e878-2950-4f7e-cfc8-7835840a558a\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"c743e878-2950-4f7e-cfc8-7835840a558a\",\"tags\":[],\"doc\":null}},{\"id\":\"80916607-4ec3-4111-c1ce-45221464354c\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"80916607-4ec3-4111-c1ce-45221464354c\",\"tags\":[],\"doc\":null}},{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"67fedde7-77f3-4be4-cbee-f8d7e302e1f3\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"e4375cef-c895-46d0-c6a9-fab205519e72\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"4323d333-fe4b-47ae-c720-624cf01f3eae\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"30478146-1415-43bc-c354-2f11b7f63741\"},{\"type\":\"LinearAxis\",\"id\":\"4323d333-fe4b-47ae-c720-624cf01f3eae\"},{\"type\":\"Grid\",\"id\":\"1aa638fb-0aeb-4e45-cebe-45eea8d8a6e4\"},{\"type\":\"LinearAxis\",\"id\":\"5cff97a7-73c3-432a-c325-b8d3f3c8984a\"},{\"type\":\"Grid\",\"id\":\"8fece7b3-34f4-4a7d-ca00-df339eec392a\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"51b3bdeb-9054-46ac-c68b-ae4a6f851315\"},{\"type\":\"WheelZoomTool\",\"id\":\"4e5f4750-9a88-4fca-cf9f-cd4ce3b7a203\"},{\"type\":\"BoxZoomTool\",\"id\":\"49fd7e0a-99e4-42c9-c230-569e198fd904\"},{\"type\":\"PreviewSaveTool\",\"id\":\"71c762a4-7339-4c46-cc34-a9cde1830045\"},{\"type\":\"ResizeTool\",\"id\":\"c743e878-2950-4f7e-cfc8-7835840a558a\"},{\"type\":\"ResetTool\",\"id\":\"80916607-4ec3-4111-c1ce-45221464354c\"}],\"doc\":null,\"right\":[],\"title\":\"Reflectivity\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"5cff97a7-73c3-432a-c325-b8d3f3c8984a\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"bf1c741c-5060-4927-c9b9-07391de6e8a4\"},\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "  Bokeh.load_models(all_models);\n",
       "  var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "  $(\"#38bd9b0b-8d2c-432c-c33c-6353b5ddd497\").html(''); // clear any previous plot in window_id\n",
       "  var view = new model.default_view({model: model, el: \"#38bd9b0b-8d2c-432c-c33c-6353b5ddd497\"});\n",
       "    } else {\n",
       "  load_lib(bokehjs_url, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", new Date())\n",
       "      var modelid = \"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\";\n",
       "      var modeltype = \"Plot\";\n",
       "      var all_models = [{\"id\":\"9ad64c8d-0dc1-490d-c9da-0dd82bac1e91\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[0,0,0,0,0,0,0,0,0,0.047065044949762,0,0,0,0,-0.11612175873732,0,0,0,0,0,0,0,0,0,0,0,0.17647058823529,0,0,0,0,0,0,0,-0.10836219693221,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"9ad64c8d-0dc1-490d-c9da-0dd82bac1e91\",\"doc\":null,\"tags\":[]}},{\"id\":\"88fe02b4-c305-4443-c4bc-51a48e8ab53c\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"blue\"},\"line_color\":{\"value\":\"blue\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"88fe02b4-c305-4443-c4bc-51a48e8ab53c\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"3de3aa81-2bc2-4514-c55b-552a597be5ee\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"blue\"},\"line_color\":{\"value\":\"blue\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"3de3aa81-2bc2-4514-c55b-552a597be5ee\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"30478146-1415-43bc-c354-2f11b7f63741\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Line\",\"id\":\"3de3aa81-2bc2-4514-c55b-552a597be5ee\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"9ad64c8d-0dc1-490d-c9da-0dd82bac1e91\"},\"glyph\":{\"type\":\"Line\",\"id\":\"88fe02b4-c305-4443-c4bc-51a48e8ab53c\"},\"selection_glyph\":null,\"id\":\"30478146-1415-43bc-c354-2f11b7f63741\",\"tags\":[]}},{\"id\":\"67fedde7-77f3-4be4-cbee-f8d7e302e1f3\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"9ad64c8d-0dc1-490d-c9da-0dd82bac1e91\"}}],\"id\":\"67fedde7-77f3-4be4-cbee-f8d7e302e1f3\",\"tags\":[],\"doc\":null}},{\"id\":\"bf1c741c-5060-4927-c9b9-07391de6e8a4\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"9ad64c8d-0dc1-490d-c9da-0dd82bac1e91\"}}],\"id\":\"bf1c741c-5060-4927-c9b9-07391de6e8a4\",\"tags\":[],\"doc\":null}},{\"id\":\"e4375cef-c895-46d0-c6a9-fab205519e72\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"e4375cef-c895-46d0-c6a9-fab205519e72\",\"geometries\":[],\"doc\":null}},{\"id\":\"648b2e60-e405-4c40-cc5b-fff61141078a\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"648b2e60-e405-4c40-cc5b-fff61141078a\",\"tags\":[],\"doc\":null}},{\"id\":\"489e075e-014c-4ef5-ce93-ac111bcdfad3\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"489e075e-014c-4ef5-ce93-ac111bcdfad3\",\"tags\":[],\"doc\":null}},{\"id\":\"4323d333-fe4b-47ae-c720-624cf01f3eae\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"648b2e60-e405-4c40-cc5b-fff61141078a\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"489e075e-014c-4ef5-ce93-ac111bcdfad3\"},\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"4323d333-fe4b-47ae-c720-624cf01f3eae\",\"doc\":null,\"tags\":[]}},{\"id\":\"1aa638fb-0aeb-4e45-cebe-45eea8d8a6e4\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"489e075e-014c-4ef5-ce93-ac111bcdfad3\"},\"id\":\"1aa638fb-0aeb-4e45-cebe-45eea8d8a6e4\",\"doc\":null,\"tags\":[]}},{\"id\":\"a5b6de1d-d2b3-4e39-ce5e-d76a30234d47\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"a5b6de1d-d2b3-4e39-ce5e-d76a30234d47\",\"tags\":[],\"doc\":null}},{\"id\":\"d8769ff3-60c1-4be2-cbef-3376017c54e6\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"d8769ff3-60c1-4be2-cbef-3376017c54e6\",\"tags\":[],\"doc\":null}},{\"id\":\"5cff97a7-73c3-432a-c325-b8d3f3c8984a\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"a5b6de1d-d2b3-4e39-ce5e-d76a30234d47\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d8769ff3-60c1-4be2-cbef-3376017c54e6\"},\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"5cff97a7-73c3-432a-c325-b8d3f3c8984a\",\"doc\":null,\"tags\":[]}},{\"id\":\"8fece7b3-34f4-4a7d-ca00-df339eec392a\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d8769ff3-60c1-4be2-cbef-3376017c54e6\"},\"id\":\"8fece7b3-34f4-4a7d-ca00-df339eec392a\",\"doc\":null,\"tags\":[]}},{\"id\":\"51b3bdeb-9054-46ac-c68b-ae4a6f851315\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"51b3bdeb-9054-46ac-c68b-ae4a6f851315\",\"doc\":null,\"tags\":[]}},{\"id\":\"4e5f4750-9a88-4fca-cf9f-cd4ce3b7a203\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"4e5f4750-9a88-4fca-cf9f-cd4ce3b7a203\",\"doc\":null,\"tags\":[]}},{\"id\":\"49fd7e0a-99e4-42c9-c230-569e198fd904\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"49fd7e0a-99e4-42c9-c230-569e198fd904\",\"tags\":[],\"doc\":null}},{\"id\":\"71c762a4-7339-4c46-cc34-a9cde1830045\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"71c762a4-7339-4c46-cc34-a9cde1830045\",\"tags\":[],\"doc\":null}},{\"id\":\"c743e878-2950-4f7e-cfc8-7835840a558a\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"c743e878-2950-4f7e-cfc8-7835840a558a\",\"tags\":[],\"doc\":null}},{\"id\":\"80916607-4ec3-4111-c1ce-45221464354c\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"80916607-4ec3-4111-c1ce-45221464354c\",\"tags\":[],\"doc\":null}},{\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"67fedde7-77f3-4be4-cbee-f8d7e302e1f3\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"e4375cef-c895-46d0-c6a9-fab205519e72\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"4323d333-fe4b-47ae-c720-624cf01f3eae\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"30478146-1415-43bc-c354-2f11b7f63741\"},{\"type\":\"LinearAxis\",\"id\":\"4323d333-fe4b-47ae-c720-624cf01f3eae\"},{\"type\":\"Grid\",\"id\":\"1aa638fb-0aeb-4e45-cebe-45eea8d8a6e4\"},{\"type\":\"LinearAxis\",\"id\":\"5cff97a7-73c3-432a-c325-b8d3f3c8984a\"},{\"type\":\"Grid\",\"id\":\"8fece7b3-34f4-4a7d-ca00-df339eec392a\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"51b3bdeb-9054-46ac-c68b-ae4a6f851315\"},{\"type\":\"WheelZoomTool\",\"id\":\"4e5f4750-9a88-4fca-cf9f-cd4ce3b7a203\"},{\"type\":\"BoxZoomTool\",\"id\":\"49fd7e0a-99e4-42c9-c230-569e198fd904\"},{\"type\":\"PreviewSaveTool\",\"id\":\"71c762a4-7339-4c46-cc34-a9cde1830045\"},{\"type\":\"ResizeTool\",\"id\":\"c743e878-2950-4f7e-cfc8-7835840a558a\"},{\"type\":\"ResetTool\",\"id\":\"80916607-4ec3-4111-c1ce-45221464354c\"}],\"doc\":null,\"right\":[],\"title\":\"Reflectivity\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"5cff97a7-73c3-432a-c325-b8d3f3c8984a\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"bf1c741c-5060-4927-c9b9-07391de6e8a4\"},\"id\":\"edb83bf6-05e3-44b6-c4a2-4de8e78dc2eb\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "      Bokeh.load_models(all_models);\n",
       "      var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "      $(\"#38bd9b0b-8d2c-432c-c33c-6353b5ddd497\").html(''); // clear any previous plot in window_id\n",
       "      var view = new model.default_view({model: model, el: \"#38bd9b0b-8d2c-432c-c33c-6353b5ddd497\"});\n",
       "  });\n",
       "    }\n",
       "});\n",
       "</script>\n",
       "<div class=\"plotdiv\" id=\"38bd9b0b-8d2c-432c-c33c-6353b5ddd497\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = torch.range(1, m:size(1))\n",
    "plot = Plot():line(x, m[{{}, 1}], 'blue')\n",
    "             :title('Reflectivity')\n",
    "             :draw()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Forward operator: convolution with wavelet\n",
    "\n",
    "Now we make the kernel matrix *G*, which represents convolution."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "t, wavelet = ricker(100, 0.02, 0.001)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script type=\"text/javascript\">\n",
       "$(function() {\n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\"){\n",
       "  window._bokeh_onload_callbacks = [];\n",
       "    }\n",
       "    function load_lib(url, callback){\n",
       "  window._bokeh_onload_callbacks.push(callback);\n",
       "  if (window._bokeh_is_loading){\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", new Date());\n",
       "      return null;\n",
       "  }\n",
       "  console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", new Date());\n",
       "  window._bokeh_is_loading = true;\n",
       "  var s = document.createElement('script');\n",
       "  s.src = url;\n",
       "  s.async = true;\n",
       "  s.onreadystatechange = s.onload = function(){\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh-0.7.0.min.css\");\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback){callback()});\n",
       "  };\n",
       "  s.onerror = function(){\n",
       "      console.warn(\"failed to load library \" + url);\n",
       "  };\n",
       "  document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "\n",
       "    bokehjs_url = \"https://cdn.pydata.org/bokeh-0.7.0.min.js\"\n",
       "\n",
       "    var elt = document.getElementById(\"fa53e8bb-63ea-4b35-cbbb-060d9521a3d0\");\n",
       "    if(elt==null) {\n",
       "  console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'fa53e8bb-63ea-4b35-cbbb-060d9521a3d0'\"\n",
       "        + \"but no matching script tag was found. \")\n",
       "  return false;\n",
       "    }\n",
       "\n",
       "    if(typeof(Bokeh) !== \"undefined\") {\n",
       "  console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "  var modelid = \"bb1614d0-945b-49bc-c939-478134e839e5\";\n",
       "  var modeltype = \"Plot\";\n",
       "  var all_models = [{\"id\":\"ba89f1af-8906-4b2e-cb32-cc24feeefc78\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[-0.0002732631773925,-0.0013795662078085,-0.0054568698668879,-0.016501001394472,-0.036138299526236,-0.048406366780454,-0.0010946000607329,0.17874535754865,0.50447464424019,0.8490912624272,1,0.8490912624272,0.50447464424019,0.17874535754865,-0.0010946000607329,-0.048406366780454,-0.036138299526236,-0.016501001394472,-0.0054568698668879,-0.0013795662078085,-0.0002732631773925],\"x\":[-0.01,-0.009,-0.008,-0.007,-0.006,-0.005,-0.004,-0.003,-0.002,-0.001,0,0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009,0.01]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"ba89f1af-8906-4b2e-cb32-cc24feeefc78\",\"doc\":null,\"tags\":[]}},{\"id\":\"6a3bde1f-0946-44d8-c4ae-464b440e8a88\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"6a3bde1f-0946-44d8-c4ae-464b440e8a88\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"c2b03050-7182-4818-c81f-517947bf8a35\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"c2b03050-7182-4818-c81f-517947bf8a35\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"70af5f75-a406-4cb3-ccd2-c2d320ffe43a\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Line\",\"id\":\"c2b03050-7182-4818-c81f-517947bf8a35\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"ba89f1af-8906-4b2e-cb32-cc24feeefc78\"},\"glyph\":{\"type\":\"Line\",\"id\":\"6a3bde1f-0946-44d8-c4ae-464b440e8a88\"},\"selection_glyph\":null,\"id\":\"70af5f75-a406-4cb3-ccd2-c2d320ffe43a\",\"tags\":[]}},{\"id\":\"d8f84276-0c60-46a2-c679-e3d3417d7849\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"ba89f1af-8906-4b2e-cb32-cc24feeefc78\"}}],\"id\":\"d8f84276-0c60-46a2-c679-e3d3417d7849\",\"tags\":[],\"doc\":null}},{\"id\":\"78b1c040-27e8-48fc-c89a-a00850c8fc2e\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"ba89f1af-8906-4b2e-cb32-cc24feeefc78\"}}],\"id\":\"78b1c040-27e8-48fc-c89a-a00850c8fc2e\",\"tags\":[],\"doc\":null}},{\"id\":\"58a0b646-0879-4622-c6ba-6be7f1680868\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"58a0b646-0879-4622-c6ba-6be7f1680868\",\"geometries\":[],\"doc\":null}},{\"id\":\"90cd3bab-7862-4102-c12a-1a4193098f73\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"90cd3bab-7862-4102-c12a-1a4193098f73\",\"tags\":[],\"doc\":null}},{\"id\":\"7d2b0a47-170c-4ac1-ca4a-6685398c9c2b\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"7d2b0a47-170c-4ac1-ca4a-6685398c9c2b\",\"tags\":[],\"doc\":null}},{\"id\":\"79655b13-5385-4dc0-cd9f-9c4590daca1a\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"90cd3bab-7862-4102-c12a-1a4193098f73\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"7d2b0a47-170c-4ac1-ca4a-6685398c9c2b\"},\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"79655b13-5385-4dc0-cd9f-9c4590daca1a\",\"doc\":null,\"tags\":[]}},{\"id\":\"49639db4-a51b-49a2-c935-bff03b70d736\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"7d2b0a47-170c-4ac1-ca4a-6685398c9c2b\"},\"id\":\"49639db4-a51b-49a2-c935-bff03b70d736\",\"doc\":null,\"tags\":[]}},{\"id\":\"ae0cac3b-e2e6-4604-c6ee-599419a12508\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"ae0cac3b-e2e6-4604-c6ee-599419a12508\",\"tags\":[],\"doc\":null}},{\"id\":\"68582311-abde-4789-c715-78a4d0c0d2cc\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"68582311-abde-4789-c715-78a4d0c0d2cc\",\"tags\":[],\"doc\":null}},{\"id\":\"54fb40ed-43a2-470e-c73d-0ef9f3665fbd\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"ae0cac3b-e2e6-4604-c6ee-599419a12508\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"68582311-abde-4789-c715-78a4d0c0d2cc\"},\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"54fb40ed-43a2-470e-c73d-0ef9f3665fbd\",\"doc\":null,\"tags\":[]}},{\"id\":\"238a02b3-e1bd-462f-c61c-130de7b273f2\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"68582311-abde-4789-c715-78a4d0c0d2cc\"},\"id\":\"238a02b3-e1bd-462f-c61c-130de7b273f2\",\"doc\":null,\"tags\":[]}},{\"id\":\"1f4bd097-4ffe-4fdd-cf4e-0f2c2a6b99f4\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"1f4bd097-4ffe-4fdd-cf4e-0f2c2a6b99f4\",\"doc\":null,\"tags\":[]}},{\"id\":\"1f07709c-9180-46ad-c656-0a5c28549279\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"1f07709c-9180-46ad-c656-0a5c28549279\",\"doc\":null,\"tags\":[]}},{\"id\":\"c9ad566e-7db4-47e1-c7e4-45f268caa4b7\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"c9ad566e-7db4-47e1-c7e4-45f268caa4b7\",\"tags\":[],\"doc\":null}},{\"id\":\"726d9651-26a7-4dbc-cde2-0196622ddb44\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"726d9651-26a7-4dbc-cde2-0196622ddb44\",\"tags\":[],\"doc\":null}},{\"id\":\"86917684-608d-4f6b-cff3-146a5c5197c7\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"86917684-608d-4f6b-cff3-146a5c5197c7\",\"tags\":[],\"doc\":null}},{\"id\":\"c63eef67-c46d-48fa-c885-6d2dba752924\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"c63eef67-c46d-48fa-c885-6d2dba752924\",\"tags\":[],\"doc\":null}},{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"d8f84276-0c60-46a2-c679-e3d3417d7849\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"58a0b646-0879-4622-c6ba-6be7f1680868\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"79655b13-5385-4dc0-cd9f-9c4590daca1a\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"70af5f75-a406-4cb3-ccd2-c2d320ffe43a\"},{\"type\":\"LinearAxis\",\"id\":\"79655b13-5385-4dc0-cd9f-9c4590daca1a\"},{\"type\":\"Grid\",\"id\":\"49639db4-a51b-49a2-c935-bff03b70d736\"},{\"type\":\"LinearAxis\",\"id\":\"54fb40ed-43a2-470e-c73d-0ef9f3665fbd\"},{\"type\":\"Grid\",\"id\":\"238a02b3-e1bd-462f-c61c-130de7b273f2\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"1f4bd097-4ffe-4fdd-cf4e-0f2c2a6b99f4\"},{\"type\":\"WheelZoomTool\",\"id\":\"1f07709c-9180-46ad-c656-0a5c28549279\"},{\"type\":\"BoxZoomTool\",\"id\":\"c9ad566e-7db4-47e1-c7e4-45f268caa4b7\"},{\"type\":\"PreviewSaveTool\",\"id\":\"726d9651-26a7-4dbc-cde2-0196622ddb44\"},{\"type\":\"ResizeTool\",\"id\":\"86917684-608d-4f6b-cff3-146a5c5197c7\"},{\"type\":\"ResetTool\",\"id\":\"c63eef67-c46d-48fa-c885-6d2dba752924\"}],\"doc\":null,\"right\":[],\"title\":\"Wavelet\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"54fb40ed-43a2-470e-c73d-0ef9f3665fbd\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"78b1c040-27e8-48fc-c89a-a00850c8fc2e\"},\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "  Bokeh.load_models(all_models);\n",
       "  var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "  $(\"#fa53e8bb-63ea-4b35-cbbb-060d9521a3d0\").html(''); // clear any previous plot in window_id\n",
       "  var view = new model.default_view({model: model, el: \"#fa53e8bb-63ea-4b35-cbbb-060d9521a3d0\"});\n",
       "    } else {\n",
       "  load_lib(bokehjs_url, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", new Date())\n",
       "      var modelid = \"bb1614d0-945b-49bc-c939-478134e839e5\";\n",
       "      var modeltype = \"Plot\";\n",
       "      var all_models = [{\"id\":\"ba89f1af-8906-4b2e-cb32-cc24feeefc78\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[-0.0002732631773925,-0.0013795662078085,-0.0054568698668879,-0.016501001394472,-0.036138299526236,-0.048406366780454,-0.0010946000607329,0.17874535754865,0.50447464424019,0.8490912624272,1,0.8490912624272,0.50447464424019,0.17874535754865,-0.0010946000607329,-0.048406366780454,-0.036138299526236,-0.016501001394472,-0.0054568698668879,-0.0013795662078085,-0.0002732631773925],\"x\":[-0.01,-0.009,-0.008,-0.007,-0.006,-0.005,-0.004,-0.003,-0.002,-0.001,0,0.001,0.002,0.003,0.004,0.005,0.006,0.007,0.008,0.009,0.01]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"ba89f1af-8906-4b2e-cb32-cc24feeefc78\",\"doc\":null,\"tags\":[]}},{\"id\":\"6a3bde1f-0946-44d8-c4ae-464b440e8a88\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"6a3bde1f-0946-44d8-c4ae-464b440e8a88\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"c2b03050-7182-4818-c81f-517947bf8a35\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"c2b03050-7182-4818-c81f-517947bf8a35\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"70af5f75-a406-4cb3-ccd2-c2d320ffe43a\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Line\",\"id\":\"c2b03050-7182-4818-c81f-517947bf8a35\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"ba89f1af-8906-4b2e-cb32-cc24feeefc78\"},\"glyph\":{\"type\":\"Line\",\"id\":\"6a3bde1f-0946-44d8-c4ae-464b440e8a88\"},\"selection_glyph\":null,\"id\":\"70af5f75-a406-4cb3-ccd2-c2d320ffe43a\",\"tags\":[]}},{\"id\":\"d8f84276-0c60-46a2-c679-e3d3417d7849\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"ba89f1af-8906-4b2e-cb32-cc24feeefc78\"}}],\"id\":\"d8f84276-0c60-46a2-c679-e3d3417d7849\",\"tags\":[],\"doc\":null}},{\"id\":\"78b1c040-27e8-48fc-c89a-a00850c8fc2e\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"ba89f1af-8906-4b2e-cb32-cc24feeefc78\"}}],\"id\":\"78b1c040-27e8-48fc-c89a-a00850c8fc2e\",\"tags\":[],\"doc\":null}},{\"id\":\"58a0b646-0879-4622-c6ba-6be7f1680868\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"58a0b646-0879-4622-c6ba-6be7f1680868\",\"geometries\":[],\"doc\":null}},{\"id\":\"90cd3bab-7862-4102-c12a-1a4193098f73\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"90cd3bab-7862-4102-c12a-1a4193098f73\",\"tags\":[],\"doc\":null}},{\"id\":\"7d2b0a47-170c-4ac1-ca4a-6685398c9c2b\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"7d2b0a47-170c-4ac1-ca4a-6685398c9c2b\",\"tags\":[],\"doc\":null}},{\"id\":\"79655b13-5385-4dc0-cd9f-9c4590daca1a\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"90cd3bab-7862-4102-c12a-1a4193098f73\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"7d2b0a47-170c-4ac1-ca4a-6685398c9c2b\"},\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"79655b13-5385-4dc0-cd9f-9c4590daca1a\",\"doc\":null,\"tags\":[]}},{\"id\":\"49639db4-a51b-49a2-c935-bff03b70d736\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"7d2b0a47-170c-4ac1-ca4a-6685398c9c2b\"},\"id\":\"49639db4-a51b-49a2-c935-bff03b70d736\",\"doc\":null,\"tags\":[]}},{\"id\":\"ae0cac3b-e2e6-4604-c6ee-599419a12508\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"ae0cac3b-e2e6-4604-c6ee-599419a12508\",\"tags\":[],\"doc\":null}},{\"id\":\"68582311-abde-4789-c715-78a4d0c0d2cc\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"68582311-abde-4789-c715-78a4d0c0d2cc\",\"tags\":[],\"doc\":null}},{\"id\":\"54fb40ed-43a2-470e-c73d-0ef9f3665fbd\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"ae0cac3b-e2e6-4604-c6ee-599419a12508\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"68582311-abde-4789-c715-78a4d0c0d2cc\"},\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"54fb40ed-43a2-470e-c73d-0ef9f3665fbd\",\"doc\":null,\"tags\":[]}},{\"id\":\"238a02b3-e1bd-462f-c61c-130de7b273f2\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"68582311-abde-4789-c715-78a4d0c0d2cc\"},\"id\":\"238a02b3-e1bd-462f-c61c-130de7b273f2\",\"doc\":null,\"tags\":[]}},{\"id\":\"1f4bd097-4ffe-4fdd-cf4e-0f2c2a6b99f4\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"1f4bd097-4ffe-4fdd-cf4e-0f2c2a6b99f4\",\"doc\":null,\"tags\":[]}},{\"id\":\"1f07709c-9180-46ad-c656-0a5c28549279\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"1f07709c-9180-46ad-c656-0a5c28549279\",\"doc\":null,\"tags\":[]}},{\"id\":\"c9ad566e-7db4-47e1-c7e4-45f268caa4b7\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"c9ad566e-7db4-47e1-c7e4-45f268caa4b7\",\"tags\":[],\"doc\":null}},{\"id\":\"726d9651-26a7-4dbc-cde2-0196622ddb44\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"726d9651-26a7-4dbc-cde2-0196622ddb44\",\"tags\":[],\"doc\":null}},{\"id\":\"86917684-608d-4f6b-cff3-146a5c5197c7\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"86917684-608d-4f6b-cff3-146a5c5197c7\",\"tags\":[],\"doc\":null}},{\"id\":\"c63eef67-c46d-48fa-c885-6d2dba752924\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"c63eef67-c46d-48fa-c885-6d2dba752924\",\"tags\":[],\"doc\":null}},{\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"d8f84276-0c60-46a2-c679-e3d3417d7849\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"58a0b646-0879-4622-c6ba-6be7f1680868\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"79655b13-5385-4dc0-cd9f-9c4590daca1a\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"70af5f75-a406-4cb3-ccd2-c2d320ffe43a\"},{\"type\":\"LinearAxis\",\"id\":\"79655b13-5385-4dc0-cd9f-9c4590daca1a\"},{\"type\":\"Grid\",\"id\":\"49639db4-a51b-49a2-c935-bff03b70d736\"},{\"type\":\"LinearAxis\",\"id\":\"54fb40ed-43a2-470e-c73d-0ef9f3665fbd\"},{\"type\":\"Grid\",\"id\":\"238a02b3-e1bd-462f-c61c-130de7b273f2\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"1f4bd097-4ffe-4fdd-cf4e-0f2c2a6b99f4\"},{\"type\":\"WheelZoomTool\",\"id\":\"1f07709c-9180-46ad-c656-0a5c28549279\"},{\"type\":\"BoxZoomTool\",\"id\":\"c9ad566e-7db4-47e1-c7e4-45f268caa4b7\"},{\"type\":\"PreviewSaveTool\",\"id\":\"726d9651-26a7-4dbc-cde2-0196622ddb44\"},{\"type\":\"ResizeTool\",\"id\":\"86917684-608d-4f6b-cff3-146a5c5197c7\"},{\"type\":\"ResetTool\",\"id\":\"c63eef67-c46d-48fa-c885-6d2dba752924\"}],\"doc\":null,\"right\":[],\"title\":\"Wavelet\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"54fb40ed-43a2-470e-c73d-0ef9f3665fbd\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"78b1c040-27e8-48fc-c89a-a00850c8fc2e\"},\"id\":\"bb1614d0-945b-49bc-c939-478134e839e5\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "      Bokeh.load_models(all_models);\n",
       "      var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "      $(\"#fa53e8bb-63ea-4b35-cbbb-060d9521a3d0\").html(''); // clear any previous plot in window_id\n",
       "      var view = new model.default_view({model: model, el: \"#fa53e8bb-63ea-4b35-cbbb-060d9521a3d0\"});\n",
       "  });\n",
       "    }\n",
       "});\n",
       "</script>\n",
       "<div class=\"plotdiv\" id=\"fa53e8bb-63ea-4b35-cbbb-060d9521a3d0\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "plot = Plot():line(t, wavelet)\n",
    "             :title('Wavelet')\n",
    "             :draw()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "G_ = convmtx(wavelet, m:size(1))[{{}, {11,60}}]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Right now, there are 50 data samples and 50 model samples. We'd like to make the problem underdetermined. So we only want the odd rows. I can't find anything quite as elegant as Python's slice 'step', but we can easily make `range` with only odd numbers using a step size, then use it to index the temporary `G_` matrix I just made: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "odd_rows = torch.range(1, G_:size(1), 2):long()\n",
    "G = G_:index(1, odd_rows)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "d = G * m"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script type=\"text/javascript\">\n",
       "$(function() {\n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\"){\n",
       "  window._bokeh_onload_callbacks = [];\n",
       "    }\n",
       "    function load_lib(url, callback){\n",
       "  window._bokeh_onload_callbacks.push(callback);\n",
       "  if (window._bokeh_is_loading){\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", new Date());\n",
       "      return null;\n",
       "  }\n",
       "  console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", new Date());\n",
       "  window._bokeh_is_loading = true;\n",
       "  var s = document.createElement('script');\n",
       "  s.src = url;\n",
       "  s.async = true;\n",
       "  s.onreadystatechange = s.onload = function(){\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh-0.7.0.min.css\");\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback){callback()});\n",
       "  };\n",
       "  s.onerror = function(){\n",
       "      console.warn(\"failed to load library \" + url);\n",
       "  };\n",
       "  document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "\n",
       "    bokehjs_url = \"https://cdn.pydata.org/bokeh-0.7.0.min.js\"\n",
       "\n",
       "    var elt = document.getElementById(\"374867bb-f5ed-4c03-cc94-c879f6a8e7fd\");\n",
       "    if(elt==null) {\n",
       "  console.log(\"Bokeh: ERROR: autoload.js configured with elementid '374867bb-f5ed-4c03-cc94-c879f6a8e7fd'\"\n",
       "        + \"but no matching script tag was found. \")\n",
       "  return false;\n",
       "    }\n",
       "\n",
       "    if(typeof(Bokeh) !== \"undefined\") {\n",
       "  console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "  var modelid = \"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\";\n",
       "  var modeltype = \"Plot\";\n",
       "  var all_models = [{\"id\":\"859ec279-368f-4bd5-cbfe-edc6559df4c5\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[-6.4929345581681e-05,-0.0007766203723469,-0.0022465160276198,0.0090463196137323,0.044158961331349,0.040089625316753,-0.050167824639965,-0.11840000656569,-0.059405326213558,-0.00090079949674856,-0.0021809040764556,0.00044049660954376,0.089086280417858,0.17706190664244,0.092940962748915,-7.4551449256777e-05,-0.061043327721681,-0.10932517396754,-0.054714203660121,0.00011861326734315,0.0039160255300572,0.00059131840714916,2.9611398242927e-05,0,0],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"859ec279-368f-4bd5-cbfe-edc6559df4c5\",\"doc\":null,\"tags\":[]}},{\"id\":\"3efc495f-e3c2-448d-c46e-43fafc3c538e\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"3efc495f-e3c2-448d-c46e-43fafc3c538e\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"a2845367-8bc9-4a0d-cab4-c2a59b2b0972\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"a2845367-8bc9-4a0d-cab4-c2a59b2b0972\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"a04ed1b4-3c62-4b65-cbb4-c3d180329b66\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Circle\",\"id\":\"a2845367-8bc9-4a0d-cab4-c2a59b2b0972\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"859ec279-368f-4bd5-cbfe-edc6559df4c5\"},\"glyph\":{\"type\":\"Circle\",\"id\":\"3efc495f-e3c2-448d-c46e-43fafc3c538e\"},\"selection_glyph\":null,\"id\":\"a04ed1b4-3c62-4b65-cbb4-c3d180329b66\",\"tags\":[]}},{\"id\":\"77eec186-0054-431c-c372-a14b085461d5\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"859ec279-368f-4bd5-cbfe-edc6559df4c5\"}}],\"id\":\"77eec186-0054-431c-c372-a14b085461d5\",\"tags\":[],\"doc\":null}},{\"id\":\"5a5b9abf-c699-4165-c113-4182642f97d5\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"859ec279-368f-4bd5-cbfe-edc6559df4c5\"}}],\"id\":\"5a5b9abf-c699-4165-c113-4182642f97d5\",\"tags\":[],\"doc\":null}},{\"id\":\"595acf0b-a9ae-4013-c05d-28642b4958df\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"595acf0b-a9ae-4013-c05d-28642b4958df\",\"geometries\":[],\"doc\":null}},{\"id\":\"e9c556fc-44be-4b94-cb22-6242330a5b29\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"e9c556fc-44be-4b94-cb22-6242330a5b29\",\"tags\":[],\"doc\":null}},{\"id\":\"63cdae29-d8e5-4d25-cd6f-c002c1bdd632\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"63cdae29-d8e5-4d25-cd6f-c002c1bdd632\",\"tags\":[],\"doc\":null}},{\"id\":\"879eedd4-3204-4e47-ce4f-e4eee7874098\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"e9c556fc-44be-4b94-cb22-6242330a5b29\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"63cdae29-d8e5-4d25-cd6f-c002c1bdd632\"},\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"879eedd4-3204-4e47-ce4f-e4eee7874098\",\"doc\":null,\"tags\":[]}},{\"id\":\"d912b050-9b49-47dd-c708-a95a55d6bb2b\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"63cdae29-d8e5-4d25-cd6f-c002c1bdd632\"},\"id\":\"d912b050-9b49-47dd-c708-a95a55d6bb2b\",\"doc\":null,\"tags\":[]}},{\"id\":\"83cf6174-83d8-4560-c54d-eeb4c0590d89\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"83cf6174-83d8-4560-c54d-eeb4c0590d89\",\"tags\":[],\"doc\":null}},{\"id\":\"c3e338b3-6705-46a9-c67d-b37158e63e27\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"c3e338b3-6705-46a9-c67d-b37158e63e27\",\"tags\":[],\"doc\":null}},{\"id\":\"84082131-4e92-4dae-cd99-46d07a0861bd\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"83cf6174-83d8-4560-c54d-eeb4c0590d89\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"c3e338b3-6705-46a9-c67d-b37158e63e27\"},\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"84082131-4e92-4dae-cd99-46d07a0861bd\",\"doc\":null,\"tags\":[]}},{\"id\":\"3b2ab9be-6086-4d96-cd0b-29e168a85086\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"c3e338b3-6705-46a9-c67d-b37158e63e27\"},\"id\":\"3b2ab9be-6086-4d96-cd0b-29e168a85086\",\"doc\":null,\"tags\":[]}},{\"id\":\"d5b747fd-daeb-4556-c591-a030e515e25b\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"d5b747fd-daeb-4556-c591-a030e515e25b\",\"doc\":null,\"tags\":[]}},{\"id\":\"69164ef6-6c17-4715-c721-37c02b62bef0\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"69164ef6-6c17-4715-c721-37c02b62bef0\",\"doc\":null,\"tags\":[]}},{\"id\":\"5ca795bb-e696-4f46-cf25-a9f5564f16c4\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"5ca795bb-e696-4f46-cf25-a9f5564f16c4\",\"tags\":[],\"doc\":null}},{\"id\":\"dead1311-a44a-466b-c6df-2e448c3ddfb8\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"dead1311-a44a-466b-c6df-2e448c3ddfb8\",\"tags\":[],\"doc\":null}},{\"id\":\"68f2fcf8-32da-40e7-c0d0-7a2a27313279\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"68f2fcf8-32da-40e7-c0d0-7a2a27313279\",\"tags\":[],\"doc\":null}},{\"id\":\"5a378944-7b3c-4520-c586-07b43985377b\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"5a378944-7b3c-4520-c586-07b43985377b\",\"tags\":[],\"doc\":null}},{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"77eec186-0054-431c-c372-a14b085461d5\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"595acf0b-a9ae-4013-c05d-28642b4958df\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"879eedd4-3204-4e47-ce4f-e4eee7874098\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"a04ed1b4-3c62-4b65-cbb4-c3d180329b66\"},{\"type\":\"LinearAxis\",\"id\":\"879eedd4-3204-4e47-ce4f-e4eee7874098\"},{\"type\":\"Grid\",\"id\":\"d912b050-9b49-47dd-c708-a95a55d6bb2b\"},{\"type\":\"LinearAxis\",\"id\":\"84082131-4e92-4dae-cd99-46d07a0861bd\"},{\"type\":\"Grid\",\"id\":\"3b2ab9be-6086-4d96-cd0b-29e168a85086\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"d5b747fd-daeb-4556-c591-a030e515e25b\"},{\"type\":\"WheelZoomTool\",\"id\":\"69164ef6-6c17-4715-c721-37c02b62bef0\"},{\"type\":\"BoxZoomTool\",\"id\":\"5ca795bb-e696-4f46-cf25-a9f5564f16c4\"},{\"type\":\"PreviewSaveTool\",\"id\":\"dead1311-a44a-466b-c6df-2e448c3ddfb8\"},{\"type\":\"ResizeTool\",\"id\":\"68f2fcf8-32da-40e7-c0d0-7a2a27313279\"},{\"type\":\"ResetTool\",\"id\":\"5a378944-7b3c-4520-c586-07b43985377b\"}],\"doc\":null,\"right\":[],\"title\":\"Data d\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"84082131-4e92-4dae-cd99-46d07a0861bd\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"5a5b9abf-c699-4165-c113-4182642f97d5\"},\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "  Bokeh.load_models(all_models);\n",
       "  var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "  $(\"#374867bb-f5ed-4c03-cc94-c879f6a8e7fd\").html(''); // clear any previous plot in window_id\n",
       "  var view = new model.default_view({model: model, el: \"#374867bb-f5ed-4c03-cc94-c879f6a8e7fd\"});\n",
       "    } else {\n",
       "  load_lib(bokehjs_url, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", new Date())\n",
       "      var modelid = \"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\";\n",
       "      var modeltype = \"Plot\";\n",
       "      var all_models = [{\"id\":\"859ec279-368f-4bd5-cbfe-edc6559df4c5\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[-6.4929345581681e-05,-0.0007766203723469,-0.0022465160276198,0.0090463196137323,0.044158961331349,0.040089625316753,-0.050167824639965,-0.11840000656569,-0.059405326213558,-0.00090079949674856,-0.0021809040764556,0.00044049660954376,0.089086280417858,0.17706190664244,0.092940962748915,-7.4551449256777e-05,-0.061043327721681,-0.10932517396754,-0.054714203660121,0.00011861326734315,0.0039160255300572,0.00059131840714916,2.9611398242927e-05,0,0],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"859ec279-368f-4bd5-cbfe-edc6559df4c5\",\"doc\":null,\"tags\":[]}},{\"id\":\"3efc495f-e3c2-448d-c46e-43fafc3c538e\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"3efc495f-e3c2-448d-c46e-43fafc3c538e\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"a2845367-8bc9-4a0d-cab4-c2a59b2b0972\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"a2845367-8bc9-4a0d-cab4-c2a59b2b0972\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"a04ed1b4-3c62-4b65-cbb4-c3d180329b66\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Circle\",\"id\":\"a2845367-8bc9-4a0d-cab4-c2a59b2b0972\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"859ec279-368f-4bd5-cbfe-edc6559df4c5\"},\"glyph\":{\"type\":\"Circle\",\"id\":\"3efc495f-e3c2-448d-c46e-43fafc3c538e\"},\"selection_glyph\":null,\"id\":\"a04ed1b4-3c62-4b65-cbb4-c3d180329b66\",\"tags\":[]}},{\"id\":\"77eec186-0054-431c-c372-a14b085461d5\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"859ec279-368f-4bd5-cbfe-edc6559df4c5\"}}],\"id\":\"77eec186-0054-431c-c372-a14b085461d5\",\"tags\":[],\"doc\":null}},{\"id\":\"5a5b9abf-c699-4165-c113-4182642f97d5\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"859ec279-368f-4bd5-cbfe-edc6559df4c5\"}}],\"id\":\"5a5b9abf-c699-4165-c113-4182642f97d5\",\"tags\":[],\"doc\":null}},{\"id\":\"595acf0b-a9ae-4013-c05d-28642b4958df\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"595acf0b-a9ae-4013-c05d-28642b4958df\",\"geometries\":[],\"doc\":null}},{\"id\":\"e9c556fc-44be-4b94-cb22-6242330a5b29\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"e9c556fc-44be-4b94-cb22-6242330a5b29\",\"tags\":[],\"doc\":null}},{\"id\":\"63cdae29-d8e5-4d25-cd6f-c002c1bdd632\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"63cdae29-d8e5-4d25-cd6f-c002c1bdd632\",\"tags\":[],\"doc\":null}},{\"id\":\"879eedd4-3204-4e47-ce4f-e4eee7874098\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"e9c556fc-44be-4b94-cb22-6242330a5b29\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"63cdae29-d8e5-4d25-cd6f-c002c1bdd632\"},\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"879eedd4-3204-4e47-ce4f-e4eee7874098\",\"doc\":null,\"tags\":[]}},{\"id\":\"d912b050-9b49-47dd-c708-a95a55d6bb2b\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"63cdae29-d8e5-4d25-cd6f-c002c1bdd632\"},\"id\":\"d912b050-9b49-47dd-c708-a95a55d6bb2b\",\"doc\":null,\"tags\":[]}},{\"id\":\"83cf6174-83d8-4560-c54d-eeb4c0590d89\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"83cf6174-83d8-4560-c54d-eeb4c0590d89\",\"tags\":[],\"doc\":null}},{\"id\":\"c3e338b3-6705-46a9-c67d-b37158e63e27\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"c3e338b3-6705-46a9-c67d-b37158e63e27\",\"tags\":[],\"doc\":null}},{\"id\":\"84082131-4e92-4dae-cd99-46d07a0861bd\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"83cf6174-83d8-4560-c54d-eeb4c0590d89\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"c3e338b3-6705-46a9-c67d-b37158e63e27\"},\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"84082131-4e92-4dae-cd99-46d07a0861bd\",\"doc\":null,\"tags\":[]}},{\"id\":\"3b2ab9be-6086-4d96-cd0b-29e168a85086\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"c3e338b3-6705-46a9-c67d-b37158e63e27\"},\"id\":\"3b2ab9be-6086-4d96-cd0b-29e168a85086\",\"doc\":null,\"tags\":[]}},{\"id\":\"d5b747fd-daeb-4556-c591-a030e515e25b\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"d5b747fd-daeb-4556-c591-a030e515e25b\",\"doc\":null,\"tags\":[]}},{\"id\":\"69164ef6-6c17-4715-c721-37c02b62bef0\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"69164ef6-6c17-4715-c721-37c02b62bef0\",\"doc\":null,\"tags\":[]}},{\"id\":\"5ca795bb-e696-4f46-cf25-a9f5564f16c4\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"5ca795bb-e696-4f46-cf25-a9f5564f16c4\",\"tags\":[],\"doc\":null}},{\"id\":\"dead1311-a44a-466b-c6df-2e448c3ddfb8\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"dead1311-a44a-466b-c6df-2e448c3ddfb8\",\"tags\":[],\"doc\":null}},{\"id\":\"68f2fcf8-32da-40e7-c0d0-7a2a27313279\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"68f2fcf8-32da-40e7-c0d0-7a2a27313279\",\"tags\":[],\"doc\":null}},{\"id\":\"5a378944-7b3c-4520-c586-07b43985377b\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"5a378944-7b3c-4520-c586-07b43985377b\",\"tags\":[],\"doc\":null}},{\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"77eec186-0054-431c-c372-a14b085461d5\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"595acf0b-a9ae-4013-c05d-28642b4958df\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"879eedd4-3204-4e47-ce4f-e4eee7874098\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"a04ed1b4-3c62-4b65-cbb4-c3d180329b66\"},{\"type\":\"LinearAxis\",\"id\":\"879eedd4-3204-4e47-ce4f-e4eee7874098\"},{\"type\":\"Grid\",\"id\":\"d912b050-9b49-47dd-c708-a95a55d6bb2b\"},{\"type\":\"LinearAxis\",\"id\":\"84082131-4e92-4dae-cd99-46d07a0861bd\"},{\"type\":\"Grid\",\"id\":\"3b2ab9be-6086-4d96-cd0b-29e168a85086\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"d5b747fd-daeb-4556-c591-a030e515e25b\"},{\"type\":\"WheelZoomTool\",\"id\":\"69164ef6-6c17-4715-c721-37c02b62bef0\"},{\"type\":\"BoxZoomTool\",\"id\":\"5ca795bb-e696-4f46-cf25-a9f5564f16c4\"},{\"type\":\"PreviewSaveTool\",\"id\":\"dead1311-a44a-466b-c6df-2e448c3ddfb8\"},{\"type\":\"ResizeTool\",\"id\":\"68f2fcf8-32da-40e7-c0d0-7a2a27313279\"},{\"type\":\"ResetTool\",\"id\":\"5a378944-7b3c-4520-c586-07b43985377b\"}],\"doc\":null,\"right\":[],\"title\":\"Data d\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"84082131-4e92-4dae-cd99-46d07a0861bd\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"5a5b9abf-c699-4165-c113-4182642f97d5\"},\"id\":\"6df259df-00d6-4c1d-cc95-9a45b54cc3c1\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "      Bokeh.load_models(all_models);\n",
       "      var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "      $(\"#374867bb-f5ed-4c03-cc94-c879f6a8e7fd\").html(''); // clear any previous plot in window_id\n",
       "      var view = new model.default_view({model: model, el: \"#374867bb-f5ed-4c03-cc94-c879f6a8e7fd\"});\n",
       "  });\n",
       "    }\n",
       "});\n",
       "</script>\n",
       "<div class=\"plotdiv\" id=\"374867bb-f5ed-4c03-cc94-c879f6a8e7fd\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = torch.range(1, d:size(1))\n",
    "plot = Plot():circle(x, d[{{}, 1}])\n",
    "             :title('Data d')\n",
    "             :draw()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Noise free: minimum norm"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "m_est = G:t() * torch.inverse(G * G:t()) * d\n",
    "d_pred = G * m_est"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script type=\"text/javascript\">\n",
       "$(function() {\n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\"){\n",
       "  window._bokeh_onload_callbacks = [];\n",
       "    }\n",
       "    function load_lib(url, callback){\n",
       "  window._bokeh_onload_callbacks.push(callback);\n",
       "  if (window._bokeh_is_loading){\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", new Date());\n",
       "      return null;\n",
       "  }\n",
       "  console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", new Date());\n",
       "  window._bokeh_is_loading = true;\n",
       "  var s = document.createElement('script');\n",
       "  s.src = url;\n",
       "  s.async = true;\n",
       "  s.onreadystatechange = s.onload = function(){\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh-0.7.0.min.css\");\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback){callback()});\n",
       "  };\n",
       "  s.onerror = function(){\n",
       "      console.warn(\"failed to load library \" + url);\n",
       "  };\n",
       "  document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "\n",
       "    bokehjs_url = \"https://cdn.pydata.org/bokeh-0.7.0.min.js\"\n",
       "\n",
       "    var elt = document.getElementById(\"0732af29-3486-49d8-c95d-796ef11efdd2\");\n",
       "    if(elt==null) {\n",
       "  console.log(\"Bokeh: ERROR: autoload.js configured with elementid '0732af29-3486-49d8-c95d-796ef11efdd2'\"\n",
       "        + \"but no matching script tag was found. \")\n",
       "  return false;\n",
       "    }\n",
       "\n",
       "    if(typeof(Bokeh) !== \"undefined\") {\n",
       "  console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "  var modelid = \"c7484057-4e31-4147-c105-8a831a95b851\";\n",
       "  var modeltype = \"Plot\";\n",
       "  var all_models = [{\"id\":\"7ca36d43-9f1c-4602-c6f8-e30d7fb8cc4f\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[0.0036381575340509,-0.0039347269891236,-0.0026961404977425,0.0042212416764012,0.0038332755650532,-0.0048449129232712,-0.0062596619846093,0.0058701167293316,0.016652476051564,0.015793248167349,0.013022775140508,0.012284214605075,-0.0029509907129176,-0.036362401605773,-0.056922137512363,-0.038357431086275,-0.00075453023031428,0.014848645236763,0.00097055706535921,-0.011656906357335,-0.0014565661960817,0.012625520045162,0.0019674346428651,-0.01867497255127,-0.0022982252745009,0.054881822684851,0.09055247641606,0.058889929608234,-0.0019817019874739,-0.023627295354811,0.0013762547129293,0.020884398036997,-0.00066601905886998,-0.040778993372778,-0.054155121941606,-0.029903284362228,0.0004251077419238,0.0079714196572799,-0.00065298048144398,-0.0040981945668264,0.00067574431280412,0.0026536936548659,-0.00054748973697173,-0.0019553063002939,0.00031652522642903,0.0015615917510572,-3.2936585899899e-06,-0.0012900738230582,-0.00034752362023043,0.0012872633398882],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"7ca36d43-9f1c-4602-c6f8-e30d7fb8cc4f\",\"doc\":null,\"tags\":[]}},{\"id\":\"f6d71c74-7cfb-4362-c349-3a585482f586\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"f6d71c74-7cfb-4362-c349-3a585482f586\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"351ac447-c818-4f0b-cf4b-2ef056d2039a\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"351ac447-c818-4f0b-cf4b-2ef056d2039a\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"68469f62-13e4-4d27-cda5-3d3e095dc96f\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Line\",\"id\":\"351ac447-c818-4f0b-cf4b-2ef056d2039a\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"7ca36d43-9f1c-4602-c6f8-e30d7fb8cc4f\"},\"glyph\":{\"type\":\"Line\",\"id\":\"f6d71c74-7cfb-4362-c349-3a585482f586\"},\"selection_glyph\":null,\"id\":\"68469f62-13e4-4d27-cda5-3d3e095dc96f\",\"tags\":[]}},{\"id\":\"5555784c-21ae-4b1e-cbe6-692d6625e94c\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"7ca36d43-9f1c-4602-c6f8-e30d7fb8cc4f\"}}],\"id\":\"5555784c-21ae-4b1e-cbe6-692d6625e94c\",\"tags\":[],\"doc\":null}},{\"id\":\"8e06e78b-290c-40ab-c0e2-f20a21239b49\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"7ca36d43-9f1c-4602-c6f8-e30d7fb8cc4f\"}}],\"id\":\"8e06e78b-290c-40ab-c0e2-f20a21239b49\",\"tags\":[],\"doc\":null}},{\"id\":\"889063d5-6197-4825-c801-0943a9477086\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"889063d5-6197-4825-c801-0943a9477086\",\"geometries\":[],\"doc\":null}},{\"id\":\"003a2821-2281-4bb6-cb26-fed19c8bdf36\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"003a2821-2281-4bb6-cb26-fed19c8bdf36\",\"tags\":[],\"doc\":null}},{\"id\":\"3b6f28be-87f8-41e7-c1f7-4faf32e3fce3\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"3b6f28be-87f8-41e7-c1f7-4faf32e3fce3\",\"tags\":[],\"doc\":null}},{\"id\":\"6f897ac0-ff26-4519-c5f3-08c00d0b87cd\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"003a2821-2281-4bb6-cb26-fed19c8bdf36\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"3b6f28be-87f8-41e7-c1f7-4faf32e3fce3\"},\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"6f897ac0-ff26-4519-c5f3-08c00d0b87cd\",\"doc\":null,\"tags\":[]}},{\"id\":\"68663a4c-d5b7-41f0-c190-4f71050f6364\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"3b6f28be-87f8-41e7-c1f7-4faf32e3fce3\"},\"id\":\"68663a4c-d5b7-41f0-c190-4f71050f6364\",\"doc\":null,\"tags\":[]}},{\"id\":\"13820127-d537-41f7-c15d-06b0f3819c39\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"13820127-d537-41f7-c15d-06b0f3819c39\",\"tags\":[],\"doc\":null}},{\"id\":\"d161191c-007f-4c6b-cc08-aae107767589\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"d161191c-007f-4c6b-cc08-aae107767589\",\"tags\":[],\"doc\":null}},{\"id\":\"8524d7ff-26bb-47ea-c79d-84963ca7d69f\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"13820127-d537-41f7-c15d-06b0f3819c39\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d161191c-007f-4c6b-cc08-aae107767589\"},\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"8524d7ff-26bb-47ea-c79d-84963ca7d69f\",\"doc\":null,\"tags\":[]}},{\"id\":\"c1508e7a-feda-48bc-c844-99fecdf5c70f\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d161191c-007f-4c6b-cc08-aae107767589\"},\"id\":\"c1508e7a-feda-48bc-c844-99fecdf5c70f\",\"doc\":null,\"tags\":[]}},{\"id\":\"a4f4fb32-1312-428a-c2e8-29e420e2b269\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"a4f4fb32-1312-428a-c2e8-29e420e2b269\",\"doc\":null,\"tags\":[]}},{\"id\":\"dcd352b8-9937-48fe-c868-47a33fb5b08a\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"dcd352b8-9937-48fe-c868-47a33fb5b08a\",\"doc\":null,\"tags\":[]}},{\"id\":\"e902e374-54d6-4bf9-cbd0-3c7392f8cfd2\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"e902e374-54d6-4bf9-cbd0-3c7392f8cfd2\",\"tags\":[],\"doc\":null}},{\"id\":\"81419d63-6947-4acb-caaf-63392739379b\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"81419d63-6947-4acb-caaf-63392739379b\",\"tags\":[],\"doc\":null}},{\"id\":\"9867469d-da41-4cfb-cc4e-312fe9f17017\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"9867469d-da41-4cfb-cc4e-312fe9f17017\",\"tags\":[],\"doc\":null}},{\"id\":\"d52203c1-2943-4c80-cce8-0b3e4df41f7c\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"d52203c1-2943-4c80-cce8-0b3e4df41f7c\",\"tags\":[],\"doc\":null}},{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"5555784c-21ae-4b1e-cbe6-692d6625e94c\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"889063d5-6197-4825-c801-0943a9477086\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"6f897ac0-ff26-4519-c5f3-08c00d0b87cd\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"68469f62-13e4-4d27-cda5-3d3e095dc96f\"},{\"type\":\"LinearAxis\",\"id\":\"6f897ac0-ff26-4519-c5f3-08c00d0b87cd\"},{\"type\":\"Grid\",\"id\":\"68663a4c-d5b7-41f0-c190-4f71050f6364\"},{\"type\":\"LinearAxis\",\"id\":\"8524d7ff-26bb-47ea-c79d-84963ca7d69f\"},{\"type\":\"Grid\",\"id\":\"c1508e7a-feda-48bc-c844-99fecdf5c70f\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"a4f4fb32-1312-428a-c2e8-29e420e2b269\"},{\"type\":\"WheelZoomTool\",\"id\":\"dcd352b8-9937-48fe-c868-47a33fb5b08a\"},{\"type\":\"BoxZoomTool\",\"id\":\"e902e374-54d6-4bf9-cbd0-3c7392f8cfd2\"},{\"type\":\"PreviewSaveTool\",\"id\":\"81419d63-6947-4acb-caaf-63392739379b\"},{\"type\":\"ResizeTool\",\"id\":\"9867469d-da41-4cfb-cc4e-312fe9f17017\"},{\"type\":\"ResetTool\",\"id\":\"d52203c1-2943-4c80-cce8-0b3e4df41f7c\"}],\"doc\":null,\"right\":[],\"title\":\"Predicted model m_est\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"8524d7ff-26bb-47ea-c79d-84963ca7d69f\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"8e06e78b-290c-40ab-c0e2-f20a21239b49\"},\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "  Bokeh.load_models(all_models);\n",
       "  var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "  $(\"#0732af29-3486-49d8-c95d-796ef11efdd2\").html(''); // clear any previous plot in window_id\n",
       "  var view = new model.default_view({model: model, el: \"#0732af29-3486-49d8-c95d-796ef11efdd2\"});\n",
       "    } else {\n",
       "  load_lib(bokehjs_url, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", new Date())\n",
       "      var modelid = \"c7484057-4e31-4147-c105-8a831a95b851\";\n",
       "      var modeltype = \"Plot\";\n",
       "      var all_models = [{\"id\":\"7ca36d43-9f1c-4602-c6f8-e30d7fb8cc4f\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[0.0036381575340509,-0.0039347269891236,-0.0026961404977425,0.0042212416764012,0.0038332755650532,-0.0048449129232712,-0.0062596619846093,0.0058701167293316,0.016652476051564,0.015793248167349,0.013022775140508,0.012284214605075,-0.0029509907129176,-0.036362401605773,-0.056922137512363,-0.038357431086275,-0.00075453023031428,0.014848645236763,0.00097055706535921,-0.011656906357335,-0.0014565661960817,0.012625520045162,0.0019674346428651,-0.01867497255127,-0.0022982252745009,0.054881822684851,0.09055247641606,0.058889929608234,-0.0019817019874739,-0.023627295354811,0.0013762547129293,0.020884398036997,-0.00066601905886998,-0.040778993372778,-0.054155121941606,-0.029903284362228,0.0004251077419238,0.0079714196572799,-0.00065298048144398,-0.0040981945668264,0.00067574431280412,0.0026536936548659,-0.00054748973697173,-0.0019553063002939,0.00031652522642903,0.0015615917510572,-3.2936585899899e-06,-0.0012900738230582,-0.00034752362023043,0.0012872633398882],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"7ca36d43-9f1c-4602-c6f8-e30d7fb8cc4f\",\"doc\":null,\"tags\":[]}},{\"id\":\"f6d71c74-7cfb-4362-c349-3a585482f586\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"f6d71c74-7cfb-4362-c349-3a585482f586\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"351ac447-c818-4f0b-cf4b-2ef056d2039a\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"351ac447-c818-4f0b-cf4b-2ef056d2039a\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"68469f62-13e4-4d27-cda5-3d3e095dc96f\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Line\",\"id\":\"351ac447-c818-4f0b-cf4b-2ef056d2039a\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"7ca36d43-9f1c-4602-c6f8-e30d7fb8cc4f\"},\"glyph\":{\"type\":\"Line\",\"id\":\"f6d71c74-7cfb-4362-c349-3a585482f586\"},\"selection_glyph\":null,\"id\":\"68469f62-13e4-4d27-cda5-3d3e095dc96f\",\"tags\":[]}},{\"id\":\"5555784c-21ae-4b1e-cbe6-692d6625e94c\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"7ca36d43-9f1c-4602-c6f8-e30d7fb8cc4f\"}}],\"id\":\"5555784c-21ae-4b1e-cbe6-692d6625e94c\",\"tags\":[],\"doc\":null}},{\"id\":\"8e06e78b-290c-40ab-c0e2-f20a21239b49\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"7ca36d43-9f1c-4602-c6f8-e30d7fb8cc4f\"}}],\"id\":\"8e06e78b-290c-40ab-c0e2-f20a21239b49\",\"tags\":[],\"doc\":null}},{\"id\":\"889063d5-6197-4825-c801-0943a9477086\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"889063d5-6197-4825-c801-0943a9477086\",\"geometries\":[],\"doc\":null}},{\"id\":\"003a2821-2281-4bb6-cb26-fed19c8bdf36\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"003a2821-2281-4bb6-cb26-fed19c8bdf36\",\"tags\":[],\"doc\":null}},{\"id\":\"3b6f28be-87f8-41e7-c1f7-4faf32e3fce3\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"3b6f28be-87f8-41e7-c1f7-4faf32e3fce3\",\"tags\":[],\"doc\":null}},{\"id\":\"6f897ac0-ff26-4519-c5f3-08c00d0b87cd\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"003a2821-2281-4bb6-cb26-fed19c8bdf36\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"3b6f28be-87f8-41e7-c1f7-4faf32e3fce3\"},\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"6f897ac0-ff26-4519-c5f3-08c00d0b87cd\",\"doc\":null,\"tags\":[]}},{\"id\":\"68663a4c-d5b7-41f0-c190-4f71050f6364\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"3b6f28be-87f8-41e7-c1f7-4faf32e3fce3\"},\"id\":\"68663a4c-d5b7-41f0-c190-4f71050f6364\",\"doc\":null,\"tags\":[]}},{\"id\":\"13820127-d537-41f7-c15d-06b0f3819c39\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"13820127-d537-41f7-c15d-06b0f3819c39\",\"tags\":[],\"doc\":null}},{\"id\":\"d161191c-007f-4c6b-cc08-aae107767589\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"d161191c-007f-4c6b-cc08-aae107767589\",\"tags\":[],\"doc\":null}},{\"id\":\"8524d7ff-26bb-47ea-c79d-84963ca7d69f\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"13820127-d537-41f7-c15d-06b0f3819c39\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d161191c-007f-4c6b-cc08-aae107767589\"},\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"8524d7ff-26bb-47ea-c79d-84963ca7d69f\",\"doc\":null,\"tags\":[]}},{\"id\":\"c1508e7a-feda-48bc-c844-99fecdf5c70f\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d161191c-007f-4c6b-cc08-aae107767589\"},\"id\":\"c1508e7a-feda-48bc-c844-99fecdf5c70f\",\"doc\":null,\"tags\":[]}},{\"id\":\"a4f4fb32-1312-428a-c2e8-29e420e2b269\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"a4f4fb32-1312-428a-c2e8-29e420e2b269\",\"doc\":null,\"tags\":[]}},{\"id\":\"dcd352b8-9937-48fe-c868-47a33fb5b08a\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"dcd352b8-9937-48fe-c868-47a33fb5b08a\",\"doc\":null,\"tags\":[]}},{\"id\":\"e902e374-54d6-4bf9-cbd0-3c7392f8cfd2\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"e902e374-54d6-4bf9-cbd0-3c7392f8cfd2\",\"tags\":[],\"doc\":null}},{\"id\":\"81419d63-6947-4acb-caaf-63392739379b\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"81419d63-6947-4acb-caaf-63392739379b\",\"tags\":[],\"doc\":null}},{\"id\":\"9867469d-da41-4cfb-cc4e-312fe9f17017\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"9867469d-da41-4cfb-cc4e-312fe9f17017\",\"tags\":[],\"doc\":null}},{\"id\":\"d52203c1-2943-4c80-cce8-0b3e4df41f7c\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"d52203c1-2943-4c80-cce8-0b3e4df41f7c\",\"tags\":[],\"doc\":null}},{\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"5555784c-21ae-4b1e-cbe6-692d6625e94c\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"889063d5-6197-4825-c801-0943a9477086\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"6f897ac0-ff26-4519-c5f3-08c00d0b87cd\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"68469f62-13e4-4d27-cda5-3d3e095dc96f\"},{\"type\":\"LinearAxis\",\"id\":\"6f897ac0-ff26-4519-c5f3-08c00d0b87cd\"},{\"type\":\"Grid\",\"id\":\"68663a4c-d5b7-41f0-c190-4f71050f6364\"},{\"type\":\"LinearAxis\",\"id\":\"8524d7ff-26bb-47ea-c79d-84963ca7d69f\"},{\"type\":\"Grid\",\"id\":\"c1508e7a-feda-48bc-c844-99fecdf5c70f\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"a4f4fb32-1312-428a-c2e8-29e420e2b269\"},{\"type\":\"WheelZoomTool\",\"id\":\"dcd352b8-9937-48fe-c868-47a33fb5b08a\"},{\"type\":\"BoxZoomTool\",\"id\":\"e902e374-54d6-4bf9-cbd0-3c7392f8cfd2\"},{\"type\":\"PreviewSaveTool\",\"id\":\"81419d63-6947-4acb-caaf-63392739379b\"},{\"type\":\"ResizeTool\",\"id\":\"9867469d-da41-4cfb-cc4e-312fe9f17017\"},{\"type\":\"ResetTool\",\"id\":\"d52203c1-2943-4c80-cce8-0b3e4df41f7c\"}],\"doc\":null,\"right\":[],\"title\":\"Predicted model m_est\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"8524d7ff-26bb-47ea-c79d-84963ca7d69f\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"8e06e78b-290c-40ab-c0e2-f20a21239b49\"},\"id\":\"c7484057-4e31-4147-c105-8a831a95b851\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "      Bokeh.load_models(all_models);\n",
       "      var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "      $(\"#0732af29-3486-49d8-c95d-796ef11efdd2\").html(''); // clear any previous plot in window_id\n",
       "      var view = new model.default_view({model: model, el: \"#0732af29-3486-49d8-c95d-796ef11efdd2\"});\n",
       "  });\n",
       "    }\n",
       "});\n",
       "</script>\n",
       "<div class=\"plotdiv\" id=\"0732af29-3486-49d8-c95d-796ef11efdd2\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = torch.range(1, m_est:size(1))\n",
    "plot = Plot():line(x, m_est[{{}, 1}])\n",
    "             :title('Predicted model m_est')\n",
    "             :draw()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script type=\"text/javascript\">\n",
       "$(function() {\n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\"){\n",
       "  window._bokeh_onload_callbacks = [];\n",
       "    }\n",
       "    function load_lib(url, callback){\n",
       "  window._bokeh_onload_callbacks.push(callback);\n",
       "  if (window._bokeh_is_loading){\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", new Date());\n",
       "      return null;\n",
       "  }\n",
       "  console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", new Date());\n",
       "  window._bokeh_is_loading = true;\n",
       "  var s = document.createElement('script');\n",
       "  s.src = url;\n",
       "  s.async = true;\n",
       "  s.onreadystatechange = s.onload = function(){\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh-0.7.0.min.css\");\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback){callback()});\n",
       "  };\n",
       "  s.onerror = function(){\n",
       "      console.warn(\"failed to load library \" + url);\n",
       "  };\n",
       "  document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "\n",
       "    bokehjs_url = \"https://cdn.pydata.org/bokeh-0.7.0.min.js\"\n",
       "\n",
       "    var elt = document.getElementById(\"23560b0b-3267-4c1a-ccf3-960d3e751db7\");\n",
       "    if(elt==null) {\n",
       "  console.log(\"Bokeh: ERROR: autoload.js configured with elementid '23560b0b-3267-4c1a-ccf3-960d3e751db7'\"\n",
       "        + \"but no matching script tag was found. \")\n",
       "  return false;\n",
       "    }\n",
       "\n",
       "    if(typeof(Bokeh) !== \"undefined\") {\n",
       "  console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "  var modelid = \"7f26662f-9866-430e-c3cb-5a97b8db7579\";\n",
       "  var modeltype = \"Plot\";\n",
       "  var all_models = [{\"id\":\"576cd5e0-b854-47c7-c7aa-6667e860a3bc\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[-6.4929345581188e-05,-0.00077662037234586,-0.0022465160276195,0.0090463196137306,0.044158961331346,0.040089625316753,-0.050167824639961,-0.11840000656569,-0.059405326213553,-0.00090079949674453,-0.0021809040764546,0.00044049660954141,0.089086280417856,0.17706190664244,0.092940962748914,-7.4551449257365e-05,-0.061043327721679,-0.10932517396754,-0.054714203660117,0.00011861326734424,0.0039160255300558,0.00059131840714778,2.9611398242826e-05,5.1979362654386e-16,1.6805133673525e-16],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"576cd5e0-b854-47c7-c7aa-6667e860a3bc\",\"doc\":null,\"tags\":[]}},{\"id\":\"3fa8ca6a-0825-414d-c166-dadcf7638543\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"3fa8ca6a-0825-414d-c166-dadcf7638543\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"e2d133b7-7f3c-409d-c09f-134ef0db5ace\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"e2d133b7-7f3c-409d-c09f-134ef0db5ace\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"e6861527-5d16-4a3c-ca77-74299ba4e55f\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Circle\",\"id\":\"e2d133b7-7f3c-409d-c09f-134ef0db5ace\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"576cd5e0-b854-47c7-c7aa-6667e860a3bc\"},\"glyph\":{\"type\":\"Circle\",\"id\":\"3fa8ca6a-0825-414d-c166-dadcf7638543\"},\"selection_glyph\":null,\"id\":\"e6861527-5d16-4a3c-ca77-74299ba4e55f\",\"tags\":[]}},{\"id\":\"8dcd2416-16f4-4dd1-cd0f-ec1a0a229ed9\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"576cd5e0-b854-47c7-c7aa-6667e860a3bc\"}}],\"id\":\"8dcd2416-16f4-4dd1-cd0f-ec1a0a229ed9\",\"tags\":[],\"doc\":null}},{\"id\":\"c7e78af2-5429-4dab-cd62-44103d0384dd\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"576cd5e0-b854-47c7-c7aa-6667e860a3bc\"}}],\"id\":\"c7e78af2-5429-4dab-cd62-44103d0384dd\",\"tags\":[],\"doc\":null}},{\"id\":\"cd4dc240-48a7-486b-c8d3-f41d24013f2d\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"cd4dc240-48a7-486b-c8d3-f41d24013f2d\",\"geometries\":[],\"doc\":null}},{\"id\":\"39eadd4a-b76a-4a44-caec-ddddaeaf56de\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"39eadd4a-b76a-4a44-caec-ddddaeaf56de\",\"tags\":[],\"doc\":null}},{\"id\":\"d9280e83-33bc-4c07-cc82-d5f4e65c802c\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"d9280e83-33bc-4c07-cc82-d5f4e65c802c\",\"tags\":[],\"doc\":null}},{\"id\":\"3822fa51-ca21-41f1-c105-3bd1aaed4f4b\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"39eadd4a-b76a-4a44-caec-ddddaeaf56de\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d9280e83-33bc-4c07-cc82-d5f4e65c802c\"},\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"3822fa51-ca21-41f1-c105-3bd1aaed4f4b\",\"doc\":null,\"tags\":[]}},{\"id\":\"8f197c3f-2586-4ae7-ca67-5ee7f74f9199\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d9280e83-33bc-4c07-cc82-d5f4e65c802c\"},\"id\":\"8f197c3f-2586-4ae7-ca67-5ee7f74f9199\",\"doc\":null,\"tags\":[]}},{\"id\":\"ef639ed0-79d7-47b1-c7a9-72b14a17c566\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"ef639ed0-79d7-47b1-c7a9-72b14a17c566\",\"tags\":[],\"doc\":null}},{\"id\":\"ed206cdd-6216-481c-c8ed-8d5f08a3edea\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"ed206cdd-6216-481c-c8ed-8d5f08a3edea\",\"tags\":[],\"doc\":null}},{\"id\":\"2dde2aef-94cf-41bf-c1b4-dc9425309739\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"ef639ed0-79d7-47b1-c7a9-72b14a17c566\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"ed206cdd-6216-481c-c8ed-8d5f08a3edea\"},\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"2dde2aef-94cf-41bf-c1b4-dc9425309739\",\"doc\":null,\"tags\":[]}},{\"id\":\"9a734023-b12c-4ddc-cd3c-b21bbce40eea\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"ed206cdd-6216-481c-c8ed-8d5f08a3edea\"},\"id\":\"9a734023-b12c-4ddc-cd3c-b21bbce40eea\",\"doc\":null,\"tags\":[]}},{\"id\":\"c5d8de29-a066-4f43-cfdb-85bd3a586243\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"c5d8de29-a066-4f43-cfdb-85bd3a586243\",\"doc\":null,\"tags\":[]}},{\"id\":\"b2fe02a8-48f5-49ca-c913-e90b878cf298\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"b2fe02a8-48f5-49ca-c913-e90b878cf298\",\"doc\":null,\"tags\":[]}},{\"id\":\"fdba9e03-761a-46c5-c616-a4bb30bf6ab3\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"fdba9e03-761a-46c5-c616-a4bb30bf6ab3\",\"tags\":[],\"doc\":null}},{\"id\":\"4db058ec-f32a-423f-c2e3-4150464d3f26\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"4db058ec-f32a-423f-c2e3-4150464d3f26\",\"tags\":[],\"doc\":null}},{\"id\":\"9202e3a1-2ff5-46c3-c61f-42bfb64d2041\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"9202e3a1-2ff5-46c3-c61f-42bfb64d2041\",\"tags\":[],\"doc\":null}},{\"id\":\"4dcfb421-12de-42e9-c218-08dbaf70abd6\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"4dcfb421-12de-42e9-c218-08dbaf70abd6\",\"tags\":[],\"doc\":null}},{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"8dcd2416-16f4-4dd1-cd0f-ec1a0a229ed9\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"cd4dc240-48a7-486b-c8d3-f41d24013f2d\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"3822fa51-ca21-41f1-c105-3bd1aaed4f4b\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"e6861527-5d16-4a3c-ca77-74299ba4e55f\"},{\"type\":\"LinearAxis\",\"id\":\"3822fa51-ca21-41f1-c105-3bd1aaed4f4b\"},{\"type\":\"Grid\",\"id\":\"8f197c3f-2586-4ae7-ca67-5ee7f74f9199\"},{\"type\":\"LinearAxis\",\"id\":\"2dde2aef-94cf-41bf-c1b4-dc9425309739\"},{\"type\":\"Grid\",\"id\":\"9a734023-b12c-4ddc-cd3c-b21bbce40eea\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"c5d8de29-a066-4f43-cfdb-85bd3a586243\"},{\"type\":\"WheelZoomTool\",\"id\":\"b2fe02a8-48f5-49ca-c913-e90b878cf298\"},{\"type\":\"BoxZoomTool\",\"id\":\"fdba9e03-761a-46c5-c616-a4bb30bf6ab3\"},{\"type\":\"PreviewSaveTool\",\"id\":\"4db058ec-f32a-423f-c2e3-4150464d3f26\"},{\"type\":\"ResizeTool\",\"id\":\"9202e3a1-2ff5-46c3-c61f-42bfb64d2041\"},{\"type\":\"ResetTool\",\"id\":\"4dcfb421-12de-42e9-c218-08dbaf70abd6\"}],\"doc\":null,\"right\":[],\"title\":\"Predicted data d_pred\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"2dde2aef-94cf-41bf-c1b4-dc9425309739\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"c7e78af2-5429-4dab-cd62-44103d0384dd\"},\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "  Bokeh.load_models(all_models);\n",
       "  var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "  $(\"#23560b0b-3267-4c1a-ccf3-960d3e751db7\").html(''); // clear any previous plot in window_id\n",
       "  var view = new model.default_view({model: model, el: \"#23560b0b-3267-4c1a-ccf3-960d3e751db7\"});\n",
       "    } else {\n",
       "  load_lib(bokehjs_url, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", new Date())\n",
       "      var modelid = \"7f26662f-9866-430e-c3cb-5a97b8db7579\";\n",
       "      var modeltype = \"Plot\";\n",
       "      var all_models = [{\"id\":\"576cd5e0-b854-47c7-c7aa-6667e860a3bc\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[-6.4929345581188e-05,-0.00077662037234586,-0.0022465160276195,0.0090463196137306,0.044158961331346,0.040089625316753,-0.050167824639961,-0.11840000656569,-0.059405326213553,-0.00090079949674453,-0.0021809040764546,0.00044049660954141,0.089086280417856,0.17706190664244,0.092940962748914,-7.4551449257365e-05,-0.061043327721679,-0.10932517396754,-0.054714203660117,0.00011861326734424,0.0039160255300558,0.00059131840714778,2.9611398242826e-05,5.1979362654386e-16,1.6805133673525e-16],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"576cd5e0-b854-47c7-c7aa-6667e860a3bc\",\"doc\":null,\"tags\":[]}},{\"id\":\"3fa8ca6a-0825-414d-c166-dadcf7638543\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"3fa8ca6a-0825-414d-c166-dadcf7638543\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"e2d133b7-7f3c-409d-c09f-134ef0db5ace\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"e2d133b7-7f3c-409d-c09f-134ef0db5ace\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"e6861527-5d16-4a3c-ca77-74299ba4e55f\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Circle\",\"id\":\"e2d133b7-7f3c-409d-c09f-134ef0db5ace\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"576cd5e0-b854-47c7-c7aa-6667e860a3bc\"},\"glyph\":{\"type\":\"Circle\",\"id\":\"3fa8ca6a-0825-414d-c166-dadcf7638543\"},\"selection_glyph\":null,\"id\":\"e6861527-5d16-4a3c-ca77-74299ba4e55f\",\"tags\":[]}},{\"id\":\"8dcd2416-16f4-4dd1-cd0f-ec1a0a229ed9\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"576cd5e0-b854-47c7-c7aa-6667e860a3bc\"}}],\"id\":\"8dcd2416-16f4-4dd1-cd0f-ec1a0a229ed9\",\"tags\":[],\"doc\":null}},{\"id\":\"c7e78af2-5429-4dab-cd62-44103d0384dd\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"576cd5e0-b854-47c7-c7aa-6667e860a3bc\"}}],\"id\":\"c7e78af2-5429-4dab-cd62-44103d0384dd\",\"tags\":[],\"doc\":null}},{\"id\":\"cd4dc240-48a7-486b-c8d3-f41d24013f2d\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"cd4dc240-48a7-486b-c8d3-f41d24013f2d\",\"geometries\":[],\"doc\":null}},{\"id\":\"39eadd4a-b76a-4a44-caec-ddddaeaf56de\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"39eadd4a-b76a-4a44-caec-ddddaeaf56de\",\"tags\":[],\"doc\":null}},{\"id\":\"d9280e83-33bc-4c07-cc82-d5f4e65c802c\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"d9280e83-33bc-4c07-cc82-d5f4e65c802c\",\"tags\":[],\"doc\":null}},{\"id\":\"3822fa51-ca21-41f1-c105-3bd1aaed4f4b\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"39eadd4a-b76a-4a44-caec-ddddaeaf56de\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d9280e83-33bc-4c07-cc82-d5f4e65c802c\"},\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"3822fa51-ca21-41f1-c105-3bd1aaed4f4b\",\"doc\":null,\"tags\":[]}},{\"id\":\"8f197c3f-2586-4ae7-ca67-5ee7f74f9199\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"d9280e83-33bc-4c07-cc82-d5f4e65c802c\"},\"id\":\"8f197c3f-2586-4ae7-ca67-5ee7f74f9199\",\"doc\":null,\"tags\":[]}},{\"id\":\"ef639ed0-79d7-47b1-c7a9-72b14a17c566\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"ef639ed0-79d7-47b1-c7a9-72b14a17c566\",\"tags\":[],\"doc\":null}},{\"id\":\"ed206cdd-6216-481c-c8ed-8d5f08a3edea\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"ed206cdd-6216-481c-c8ed-8d5f08a3edea\",\"tags\":[],\"doc\":null}},{\"id\":\"2dde2aef-94cf-41bf-c1b4-dc9425309739\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"ef639ed0-79d7-47b1-c7a9-72b14a17c566\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"ed206cdd-6216-481c-c8ed-8d5f08a3edea\"},\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"2dde2aef-94cf-41bf-c1b4-dc9425309739\",\"doc\":null,\"tags\":[]}},{\"id\":\"9a734023-b12c-4ddc-cd3c-b21bbce40eea\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"ed206cdd-6216-481c-c8ed-8d5f08a3edea\"},\"id\":\"9a734023-b12c-4ddc-cd3c-b21bbce40eea\",\"doc\":null,\"tags\":[]}},{\"id\":\"c5d8de29-a066-4f43-cfdb-85bd3a586243\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"c5d8de29-a066-4f43-cfdb-85bd3a586243\",\"doc\":null,\"tags\":[]}},{\"id\":\"b2fe02a8-48f5-49ca-c913-e90b878cf298\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"b2fe02a8-48f5-49ca-c913-e90b878cf298\",\"doc\":null,\"tags\":[]}},{\"id\":\"fdba9e03-761a-46c5-c616-a4bb30bf6ab3\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"fdba9e03-761a-46c5-c616-a4bb30bf6ab3\",\"tags\":[],\"doc\":null}},{\"id\":\"4db058ec-f32a-423f-c2e3-4150464d3f26\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"4db058ec-f32a-423f-c2e3-4150464d3f26\",\"tags\":[],\"doc\":null}},{\"id\":\"9202e3a1-2ff5-46c3-c61f-42bfb64d2041\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"9202e3a1-2ff5-46c3-c61f-42bfb64d2041\",\"tags\":[],\"doc\":null}},{\"id\":\"4dcfb421-12de-42e9-c218-08dbaf70abd6\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"4dcfb421-12de-42e9-c218-08dbaf70abd6\",\"tags\":[],\"doc\":null}},{\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"8dcd2416-16f4-4dd1-cd0f-ec1a0a229ed9\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"cd4dc240-48a7-486b-c8d3-f41d24013f2d\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"3822fa51-ca21-41f1-c105-3bd1aaed4f4b\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"e6861527-5d16-4a3c-ca77-74299ba4e55f\"},{\"type\":\"LinearAxis\",\"id\":\"3822fa51-ca21-41f1-c105-3bd1aaed4f4b\"},{\"type\":\"Grid\",\"id\":\"8f197c3f-2586-4ae7-ca67-5ee7f74f9199\"},{\"type\":\"LinearAxis\",\"id\":\"2dde2aef-94cf-41bf-c1b4-dc9425309739\"},{\"type\":\"Grid\",\"id\":\"9a734023-b12c-4ddc-cd3c-b21bbce40eea\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"c5d8de29-a066-4f43-cfdb-85bd3a586243\"},{\"type\":\"WheelZoomTool\",\"id\":\"b2fe02a8-48f5-49ca-c913-e90b878cf298\"},{\"type\":\"BoxZoomTool\",\"id\":\"fdba9e03-761a-46c5-c616-a4bb30bf6ab3\"},{\"type\":\"PreviewSaveTool\",\"id\":\"4db058ec-f32a-423f-c2e3-4150464d3f26\"},{\"type\":\"ResizeTool\",\"id\":\"9202e3a1-2ff5-46c3-c61f-42bfb64d2041\"},{\"type\":\"ResetTool\",\"id\":\"4dcfb421-12de-42e9-c218-08dbaf70abd6\"}],\"doc\":null,\"right\":[],\"title\":\"Predicted data d_pred\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"2dde2aef-94cf-41bf-c1b4-dc9425309739\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"c7e78af2-5429-4dab-cd62-44103d0384dd\"},\"id\":\"7f26662f-9866-430e-c3cb-5a97b8db7579\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "      Bokeh.load_models(all_models);\n",
       "      var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "      $(\"#23560b0b-3267-4c1a-ccf3-960d3e751db7\").html(''); // clear any previous plot in window_id\n",
       "      var view = new model.default_view({model: model, el: \"#23560b0b-3267-4c1a-ccf3-960d3e751db7\"});\n",
       "  });\n",
       "    }\n",
       "});\n",
       "</script>\n",
       "<div class=\"plotdiv\" id=\"23560b0b-3267-4c1a-ccf3-960d3e751db7\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = torch.range(1, d_pred:size(1))\n",
    "plot = Plot():circle(x, d_pred[{{}, 1}])\n",
    "             :title('Predicted data d_pred')\n",
    "             :draw()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Least squares solution using GESV\n",
    "\n",
    "This uses LAPACK. It proceeds via factorization instead of the inverse of (G * G.T). It's the equivalent of calling NumPy or SciPy's `linalg.solve` function."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script type=\"text/javascript\">\n",
       "$(function() {\n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\"){\n",
       "  window._bokeh_onload_callbacks = [];\n",
       "    }\n",
       "    function load_lib(url, callback){\n",
       "  window._bokeh_onload_callbacks.push(callback);\n",
       "  if (window._bokeh_is_loading){\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", new Date());\n",
       "      return null;\n",
       "  }\n",
       "  console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", new Date());\n",
       "  window._bokeh_is_loading = true;\n",
       "  var s = document.createElement('script');\n",
       "  s.src = url;\n",
       "  s.async = true;\n",
       "  s.onreadystatechange = s.onload = function(){\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh-0.7.0.min.css\");\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback){callback()});\n",
       "  };\n",
       "  s.onerror = function(){\n",
       "      console.warn(\"failed to load library \" + url);\n",
       "  };\n",
       "  document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "\n",
       "    bokehjs_url = \"https://cdn.pydata.org/bokeh-0.7.0.min.js\"\n",
       "\n",
       "    var elt = document.getElementById(\"df53d30f-15e2-48ed-c856-9e298e3679ba\");\n",
       "    if(elt==null) {\n",
       "  console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'df53d30f-15e2-48ed-c856-9e298e3679ba'\"\n",
       "        + \"but no matching script tag was found. \")\n",
       "  return false;\n",
       "    }\n",
       "\n",
       "    if(typeof(Bokeh) !== \"undefined\") {\n",
       "  console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "  var modelid = \"54733f11-fb69-4ee3-ce8d-4aac9274e62c\";\n",
       "  var modeltype = \"Plot\";\n",
       "  var all_models = [{\"id\":\"24d6e89d-16b0-4fad-cfcd-938e07a048b2\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[-6.4929345581681e-05,-0.0007766203723469,-0.0022465160276198,0.0090463196137323,0.044158961331349,0.040089625316753,-0.050167824639965,-0.11840000656569,-0.059405326213558,-0.00090079949674856,-0.0021809040764556,0.00044049660954376,0.089086280417858,0.17706190664244,0.092940962748915,-7.4551449256777e-05,-0.061043327721681,-0.10932517396754,-0.054714203660121,0.00011861326734315,0.0039160255300572,0.00059131840714916,2.9611398242927e-05,0,0],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"24d6e89d-16b0-4fad-cfcd-938e07a048b2\",\"doc\":null,\"tags\":[]}},{\"id\":\"6496e80c-2930-4771-c7c3-4d76b5a99164\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"blue\"},\"line_color\":{\"value\":\"blue\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"6496e80c-2930-4771-c7c3-4d76b5a99164\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"b307a2f6-0b71-44c9-c475-b84cd872bf05\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"blue\"},\"line_color\":{\"value\":\"blue\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"b307a2f6-0b71-44c9-c475-b84cd872bf05\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"11e9f07e-a9b9-4695-c63e-d2e0ea283649\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Circle\",\"id\":\"b307a2f6-0b71-44c9-c475-b84cd872bf05\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"24d6e89d-16b0-4fad-cfcd-938e07a048b2\"},\"glyph\":{\"type\":\"Circle\",\"id\":\"6496e80c-2930-4771-c7c3-4d76b5a99164\"},\"selection_glyph\":null,\"id\":\"11e9f07e-a9b9-4695-c63e-d2e0ea283649\",\"tags\":[]}},{\"id\":\"83863e46-7f84-4408-c40b-e3f1c979c535\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[-6.4929345581682e-05,-0.0007766203723469,-0.0022465160276198,0.0090463196137323,0.044158961331349,0.040089625316753,-0.050167824639965,-0.11840000656569,-0.059405326213558,-0.00090079949674854,-0.0021809040764556,0.00044049660954375,0.089086280417858,0.17706190664244,0.092940962748915,-7.4551449256803e-05,-0.061043327721681,-0.10932517396754,-0.054714203660121,0.00011861326734316,0.0039160255300572,0.00059131840714916,2.9611398242926e-05,1.2468324983583e-18,1.5178830414797e-18],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"83863e46-7f84-4408-c40b-e3f1c979c535\",\"doc\":null,\"tags\":[]}},{\"id\":\"cd2db6ca-9f16-483e-c809-02a50c7a87cf\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"cd2db6ca-9f16-483e-c809-02a50c7a87cf\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"fafa68b0-7eef-453d-c55c-a9df41aef3e6\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"fafa68b0-7eef-453d-c55c-a9df41aef3e6\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"e60871d9-a5a5-4b46-cbe4-21f392c55cc4\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Circle\",\"id\":\"fafa68b0-7eef-453d-c55c-a9df41aef3e6\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"83863e46-7f84-4408-c40b-e3f1c979c535\"},\"glyph\":{\"type\":\"Circle\",\"id\":\"cd2db6ca-9f16-483e-c809-02a50c7a87cf\"},\"selection_glyph\":null,\"id\":\"e60871d9-a5a5-4b46-cbe4-21f392c55cc4\",\"tags\":[]}},{\"id\":\"2d5f0fa2-45de-489c-c80f-3a284921e719\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"24d6e89d-16b0-4fad-cfcd-938e07a048b2\"}},{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"83863e46-7f84-4408-c40b-e3f1c979c535\"}}],\"id\":\"2d5f0fa2-45de-489c-c80f-3a284921e719\",\"tags\":[],\"doc\":null}},{\"id\":\"946b547e-c9ec-47d7-c70c-f8dba3f7bb6e\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"24d6e89d-16b0-4fad-cfcd-938e07a048b2\"}},{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"83863e46-7f84-4408-c40b-e3f1c979c535\"}}],\"id\":\"946b547e-c9ec-47d7-c70c-f8dba3f7bb6e\",\"tags\":[],\"doc\":null}},{\"id\":\"19dfee05-f41d-4712-c72b-28b63b83a61a\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"19dfee05-f41d-4712-c72b-28b63b83a61a\",\"geometries\":[],\"doc\":null}},{\"id\":\"bdf7a075-d2b5-41e2-c151-7bb1aac9ef46\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"bdf7a075-d2b5-41e2-c151-7bb1aac9ef46\",\"tags\":[],\"doc\":null}},{\"id\":\"c8127d0d-9c5b-45b6-c520-b6358e936b4c\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"c8127d0d-9c5b-45b6-c520-b6358e936b4c\",\"tags\":[],\"doc\":null}},{\"id\":\"8de6f979-f1dd-44f2-c48e-67e2322f1c48\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"bdf7a075-d2b5-41e2-c151-7bb1aac9ef46\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"c8127d0d-9c5b-45b6-c520-b6358e936b4c\"},\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"8de6f979-f1dd-44f2-c48e-67e2322f1c48\",\"doc\":null,\"tags\":[]}},{\"id\":\"b03c92e6-75d7-4ba7-cb45-7bf209d0fa0c\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"c8127d0d-9c5b-45b6-c520-b6358e936b4c\"},\"id\":\"b03c92e6-75d7-4ba7-cb45-7bf209d0fa0c\",\"doc\":null,\"tags\":[]}},{\"id\":\"73e92ee0-dc65-4137-c18d-34a3381c4052\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"73e92ee0-dc65-4137-c18d-34a3381c4052\",\"tags\":[],\"doc\":null}},{\"id\":\"72d1e3bd-3fd3-4a3c-cac3-aedcf9b0550e\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"72d1e3bd-3fd3-4a3c-cac3-aedcf9b0550e\",\"tags\":[],\"doc\":null}},{\"id\":\"6d4bb37b-d0fb-47cc-c704-2b7ff6bfc2cb\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"73e92ee0-dc65-4137-c18d-34a3381c4052\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"72d1e3bd-3fd3-4a3c-cac3-aedcf9b0550e\"},\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"6d4bb37b-d0fb-47cc-c704-2b7ff6bfc2cb\",\"doc\":null,\"tags\":[]}},{\"id\":\"442e3b75-f8a9-401d-c09a-f29a9fd2bd54\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"72d1e3bd-3fd3-4a3c-cac3-aedcf9b0550e\"},\"id\":\"442e3b75-f8a9-401d-c09a-f29a9fd2bd54\",\"doc\":null,\"tags\":[]}},{\"id\":\"9ce24391-45bb-4be7-cb2a-059464107515\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"9ce24391-45bb-4be7-cb2a-059464107515\",\"doc\":null,\"tags\":[]}},{\"id\":\"b05b74bc-be85-4ff9-cfd0-eac697af0391\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"b05b74bc-be85-4ff9-cfd0-eac697af0391\",\"doc\":null,\"tags\":[]}},{\"id\":\"81e7c1c2-2756-4c06-cc7d-afc5e76081be\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"81e7c1c2-2756-4c06-cc7d-afc5e76081be\",\"tags\":[],\"doc\":null}},{\"id\":\"b4f24390-ccf7-440f-c4d8-d750fec3b4cc\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"b4f24390-ccf7-440f-c4d8-d750fec3b4cc\",\"tags\":[],\"doc\":null}},{\"id\":\"67d1d42a-5835-4fac-cf39-5639ed59f3a5\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"67d1d42a-5835-4fac-cf39-5639ed59f3a5\",\"tags\":[],\"doc\":null}},{\"id\":\"2ec5695e-0b33-4846-c837-8246d7857d35\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"2ec5695e-0b33-4846-c837-8246d7857d35\",\"tags\":[],\"doc\":null}},{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"2d5f0fa2-45de-489c-c80f-3a284921e719\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"19dfee05-f41d-4712-c72b-28b63b83a61a\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"8de6f979-f1dd-44f2-c48e-67e2322f1c48\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"11e9f07e-a9b9-4695-c63e-d2e0ea283649\"},{\"type\":\"GlyphRenderer\",\"id\":\"e60871d9-a5a5-4b46-cbe4-21f392c55cc4\"},{\"type\":\"LinearAxis\",\"id\":\"8de6f979-f1dd-44f2-c48e-67e2322f1c48\"},{\"type\":\"Grid\",\"id\":\"b03c92e6-75d7-4ba7-cb45-7bf209d0fa0c\"},{\"type\":\"LinearAxis\",\"id\":\"6d4bb37b-d0fb-47cc-c704-2b7ff6bfc2cb\"},{\"type\":\"Grid\",\"id\":\"442e3b75-f8a9-401d-c09a-f29a9fd2bd54\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"9ce24391-45bb-4be7-cb2a-059464107515\"},{\"type\":\"WheelZoomTool\",\"id\":\"b05b74bc-be85-4ff9-cfd0-eac697af0391\"},{\"type\":\"BoxZoomTool\",\"id\":\"81e7c1c2-2756-4c06-cc7d-afc5e76081be\"},{\"type\":\"PreviewSaveTool\",\"id\":\"b4f24390-ccf7-440f-c4d8-d750fec3b4cc\"},{\"type\":\"ResizeTool\",\"id\":\"67d1d42a-5835-4fac-cf39-5639ed59f3a5\"},{\"type\":\"ResetTool\",\"id\":\"2ec5695e-0b33-4846-c837-8246d7857d35\"}],\"doc\":null,\"right\":[],\"title\":\"blue:d   red:d_pred\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"6d4bb37b-d0fb-47cc-c704-2b7ff6bfc2cb\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"946b547e-c9ec-47d7-c70c-f8dba3f7bb6e\"},\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "  Bokeh.load_models(all_models);\n",
       "  var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "  $(\"#df53d30f-15e2-48ed-c856-9e298e3679ba\").html(''); // clear any previous plot in window_id\n",
       "  var view = new model.default_view({model: model, el: \"#df53d30f-15e2-48ed-c856-9e298e3679ba\"});\n",
       "    } else {\n",
       "  load_lib(bokehjs_url, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", new Date())\n",
       "      var modelid = \"54733f11-fb69-4ee3-ce8d-4aac9274e62c\";\n",
       "      var modeltype = \"Plot\";\n",
       "      var all_models = [{\"id\":\"24d6e89d-16b0-4fad-cfcd-938e07a048b2\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[-6.4929345581681e-05,-0.0007766203723469,-0.0022465160276198,0.0090463196137323,0.044158961331349,0.040089625316753,-0.050167824639965,-0.11840000656569,-0.059405326213558,-0.00090079949674856,-0.0021809040764556,0.00044049660954376,0.089086280417858,0.17706190664244,0.092940962748915,-7.4551449256777e-05,-0.061043327721681,-0.10932517396754,-0.054714203660121,0.00011861326734315,0.0039160255300572,0.00059131840714916,2.9611398242927e-05,0,0],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"24d6e89d-16b0-4fad-cfcd-938e07a048b2\",\"doc\":null,\"tags\":[]}},{\"id\":\"6496e80c-2930-4771-c7c3-4d76b5a99164\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"blue\"},\"line_color\":{\"value\":\"blue\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"6496e80c-2930-4771-c7c3-4d76b5a99164\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"b307a2f6-0b71-44c9-c475-b84cd872bf05\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"blue\"},\"line_color\":{\"value\":\"blue\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"b307a2f6-0b71-44c9-c475-b84cd872bf05\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"11e9f07e-a9b9-4695-c63e-d2e0ea283649\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Circle\",\"id\":\"b307a2f6-0b71-44c9-c475-b84cd872bf05\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"24d6e89d-16b0-4fad-cfcd-938e07a048b2\"},\"glyph\":{\"type\":\"Circle\",\"id\":\"6496e80c-2930-4771-c7c3-4d76b5a99164\"},\"selection_glyph\":null,\"id\":\"11e9f07e-a9b9-4695-c63e-d2e0ea283649\",\"tags\":[]}},{\"id\":\"83863e46-7f84-4408-c40b-e3f1c979c535\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[-6.4929345581682e-05,-0.0007766203723469,-0.0022465160276198,0.0090463196137323,0.044158961331349,0.040089625316753,-0.050167824639965,-0.11840000656569,-0.059405326213558,-0.00090079949674854,-0.0021809040764556,0.00044049660954375,0.089086280417858,0.17706190664244,0.092940962748915,-7.4551449256803e-05,-0.061043327721681,-0.10932517396754,-0.054714203660121,0.00011861326734316,0.0039160255300572,0.00059131840714916,2.9611398242926e-05,1.2468324983583e-18,1.5178830414797e-18],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"83863e46-7f84-4408-c40b-e3f1c979c535\",\"doc\":null,\"tags\":[]}},{\"id\":\"cd2db6ca-9f16-483e-c809-02a50c7a87cf\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"cd2db6ca-9f16-483e-c809-02a50c7a87cf\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"fafa68b0-7eef-453d-c55c-a9df41aef3e6\",\"type\":\"Circle\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"fafa68b0-7eef-453d-c55c-a9df41aef3e6\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"e60871d9-a5a5-4b46-cbe4-21f392c55cc4\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Circle\",\"id\":\"fafa68b0-7eef-453d-c55c-a9df41aef3e6\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"83863e46-7f84-4408-c40b-e3f1c979c535\"},\"glyph\":{\"type\":\"Circle\",\"id\":\"cd2db6ca-9f16-483e-c809-02a50c7a87cf\"},\"selection_glyph\":null,\"id\":\"e60871d9-a5a5-4b46-cbe4-21f392c55cc4\",\"tags\":[]}},{\"id\":\"2d5f0fa2-45de-489c-c80f-3a284921e719\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"24d6e89d-16b0-4fad-cfcd-938e07a048b2\"}},{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"83863e46-7f84-4408-c40b-e3f1c979c535\"}}],\"id\":\"2d5f0fa2-45de-489c-c80f-3a284921e719\",\"tags\":[],\"doc\":null}},{\"id\":\"946b547e-c9ec-47d7-c70c-f8dba3f7bb6e\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"24d6e89d-16b0-4fad-cfcd-938e07a048b2\"}},{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"83863e46-7f84-4408-c40b-e3f1c979c535\"}}],\"id\":\"946b547e-c9ec-47d7-c70c-f8dba3f7bb6e\",\"tags\":[],\"doc\":null}},{\"id\":\"19dfee05-f41d-4712-c72b-28b63b83a61a\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"19dfee05-f41d-4712-c72b-28b63b83a61a\",\"geometries\":[],\"doc\":null}},{\"id\":\"bdf7a075-d2b5-41e2-c151-7bb1aac9ef46\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"bdf7a075-d2b5-41e2-c151-7bb1aac9ef46\",\"tags\":[],\"doc\":null}},{\"id\":\"c8127d0d-9c5b-45b6-c520-b6358e936b4c\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"c8127d0d-9c5b-45b6-c520-b6358e936b4c\",\"tags\":[],\"doc\":null}},{\"id\":\"8de6f979-f1dd-44f2-c48e-67e2322f1c48\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"bdf7a075-d2b5-41e2-c151-7bb1aac9ef46\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"c8127d0d-9c5b-45b6-c520-b6358e936b4c\"},\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"8de6f979-f1dd-44f2-c48e-67e2322f1c48\",\"doc\":null,\"tags\":[]}},{\"id\":\"b03c92e6-75d7-4ba7-cb45-7bf209d0fa0c\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"c8127d0d-9c5b-45b6-c520-b6358e936b4c\"},\"id\":\"b03c92e6-75d7-4ba7-cb45-7bf209d0fa0c\",\"doc\":null,\"tags\":[]}},{\"id\":\"73e92ee0-dc65-4137-c18d-34a3381c4052\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"73e92ee0-dc65-4137-c18d-34a3381c4052\",\"tags\":[],\"doc\":null}},{\"id\":\"72d1e3bd-3fd3-4a3c-cac3-aedcf9b0550e\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"72d1e3bd-3fd3-4a3c-cac3-aedcf9b0550e\",\"tags\":[],\"doc\":null}},{\"id\":\"6d4bb37b-d0fb-47cc-c704-2b7ff6bfc2cb\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"73e92ee0-dc65-4137-c18d-34a3381c4052\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"72d1e3bd-3fd3-4a3c-cac3-aedcf9b0550e\"},\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"6d4bb37b-d0fb-47cc-c704-2b7ff6bfc2cb\",\"doc\":null,\"tags\":[]}},{\"id\":\"442e3b75-f8a9-401d-c09a-f29a9fd2bd54\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"72d1e3bd-3fd3-4a3c-cac3-aedcf9b0550e\"},\"id\":\"442e3b75-f8a9-401d-c09a-f29a9fd2bd54\",\"doc\":null,\"tags\":[]}},{\"id\":\"9ce24391-45bb-4be7-cb2a-059464107515\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"9ce24391-45bb-4be7-cb2a-059464107515\",\"doc\":null,\"tags\":[]}},{\"id\":\"b05b74bc-be85-4ff9-cfd0-eac697af0391\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"b05b74bc-be85-4ff9-cfd0-eac697af0391\",\"doc\":null,\"tags\":[]}},{\"id\":\"81e7c1c2-2756-4c06-cc7d-afc5e76081be\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"81e7c1c2-2756-4c06-cc7d-afc5e76081be\",\"tags\":[],\"doc\":null}},{\"id\":\"b4f24390-ccf7-440f-c4d8-d750fec3b4cc\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"b4f24390-ccf7-440f-c4d8-d750fec3b4cc\",\"tags\":[],\"doc\":null}},{\"id\":\"67d1d42a-5835-4fac-cf39-5639ed59f3a5\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"67d1d42a-5835-4fac-cf39-5639ed59f3a5\",\"tags\":[],\"doc\":null}},{\"id\":\"2ec5695e-0b33-4846-c837-8246d7857d35\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"2ec5695e-0b33-4846-c837-8246d7857d35\",\"tags\":[],\"doc\":null}},{\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"2d5f0fa2-45de-489c-c80f-3a284921e719\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"19dfee05-f41d-4712-c72b-28b63b83a61a\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"8de6f979-f1dd-44f2-c48e-67e2322f1c48\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"11e9f07e-a9b9-4695-c63e-d2e0ea283649\"},{\"type\":\"GlyphRenderer\",\"id\":\"e60871d9-a5a5-4b46-cbe4-21f392c55cc4\"},{\"type\":\"LinearAxis\",\"id\":\"8de6f979-f1dd-44f2-c48e-67e2322f1c48\"},{\"type\":\"Grid\",\"id\":\"b03c92e6-75d7-4ba7-cb45-7bf209d0fa0c\"},{\"type\":\"LinearAxis\",\"id\":\"6d4bb37b-d0fb-47cc-c704-2b7ff6bfc2cb\"},{\"type\":\"Grid\",\"id\":\"442e3b75-f8a9-401d-c09a-f29a9fd2bd54\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"9ce24391-45bb-4be7-cb2a-059464107515\"},{\"type\":\"WheelZoomTool\",\"id\":\"b05b74bc-be85-4ff9-cfd0-eac697af0391\"},{\"type\":\"BoxZoomTool\",\"id\":\"81e7c1c2-2756-4c06-cc7d-afc5e76081be\"},{\"type\":\"PreviewSaveTool\",\"id\":\"b4f24390-ccf7-440f-c4d8-d750fec3b4cc\"},{\"type\":\"ResizeTool\",\"id\":\"67d1d42a-5835-4fac-cf39-5639ed59f3a5\"},{\"type\":\"ResetTool\",\"id\":\"2ec5695e-0b33-4846-c837-8246d7857d35\"}],\"doc\":null,\"right\":[],\"title\":\"blue:d   red:d_pred\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"6d4bb37b-d0fb-47cc-c704-2b7ff6bfc2cb\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"946b547e-c9ec-47d7-c70c-f8dba3f7bb6e\"},\"id\":\"54733f11-fb69-4ee3-ce8d-4aac9274e62c\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "      Bokeh.load_models(all_models);\n",
       "      var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "      $(\"#df53d30f-15e2-48ed-c856-9e298e3679ba\").html(''); // clear any previous plot in window_id\n",
       "      var view = new model.default_view({model: model, el: \"#df53d30f-15e2-48ed-c856-9e298e3679ba\"});\n",
       "  });\n",
       "    }\n",
       "});\n",
       "</script>\n",
       "<div class=\"plotdiv\" id=\"df53d30f-15e2-48ed-c856-9e298e3679ba\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "-- Use torch.gels()\n",
    "m_est = torch.gels(d, G)\n",
    "d_pred = G * m_est\n",
    "\n",
    "-- Plot\n",
    "x = torch.range(1,d_pred:size(1))\n",
    "plot = Plot():circle(x, d[{{},1}], 'blue')\n",
    "             :circle(x, d_pred[{{},1}], 'red')\n",
    "             :title('blue:d   red:d_pred')\n",
    "             :draw()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script type=\"text/javascript\">\n",
       "$(function() {\n",
       "    if (typeof (window._bokeh_onload_callbacks) === \"undefined\"){\n",
       "  window._bokeh_onload_callbacks = [];\n",
       "    }\n",
       "    function load_lib(url, callback){\n",
       "  window._bokeh_onload_callbacks.push(callback);\n",
       "  if (window._bokeh_is_loading){\n",
       "      console.log(\"Bokeh: BokehJS is being loaded, scheduling callback at\", new Date());\n",
       "      return null;\n",
       "  }\n",
       "  console.log(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", new Date());\n",
       "  window._bokeh_is_loading = true;\n",
       "  var s = document.createElement('script');\n",
       "  s.src = url;\n",
       "  s.async = true;\n",
       "  s.onreadystatechange = s.onload = function(){\n",
       "      Bokeh.embed.inject_css(\"https://cdn.pydata.org/bokeh-0.7.0.min.css\");\n",
       "      window._bokeh_onload_callbacks.forEach(function(callback){callback()});\n",
       "  };\n",
       "  s.onerror = function(){\n",
       "      console.warn(\"failed to load library \" + url);\n",
       "  };\n",
       "  document.getElementsByTagName(\"head\")[0].appendChild(s);\n",
       "    }\n",
       "\n",
       "    bokehjs_url = \"https://cdn.pydata.org/bokeh-0.7.0.min.js\"\n",
       "\n",
       "    var elt = document.getElementById(\"c3e914dd-9ef0-4d30-cdc5-0950b2e84f97\");\n",
       "    if(elt==null) {\n",
       "  console.log(\"Bokeh: ERROR: autoload.js configured with elementid 'c3e914dd-9ef0-4d30-cdc5-0950b2e84f97'\"\n",
       "        + \"but no matching script tag was found. \")\n",
       "  return false;\n",
       "    }\n",
       "\n",
       "    if(typeof(Bokeh) !== \"undefined\") {\n",
       "  console.log(\"Bokeh: BokehJS loaded, going straight to plotting\");\n",
       "  var modelid = \"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\";\n",
       "  var modeltype = \"Plot\";\n",
       "  var all_models = [{\"id\":\"9c238f85-9a92-4dd3-cdf4-7247f041e224\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[0.0036381575340517,-0.0039347269891247,-0.0026961404977435,0.0042212416764015,0.0038332755650542,-0.004844912923272,-0.00625966198461,0.0058701167293327,0.016652476051567,0.01579324816735,0.013022775140507,0.012284214605074,-0.0029509907129178,-0.036362401605774,-0.056922137512365,-0.038357431086277,-0.00075453023031455,0.014848645236763,0.00097055706535791,-0.011656906357337,-0.0014565661960826,0.012625520045164,0.0019674346428672,-0.01867497255127,-0.0022982252745018,0.054881822684851,0.090552476416062,0.058889929608234,-0.0019817019874752,-0.023627295354811,0.0013762547129304,0.020884398036998,-0.00066601905887153,-0.040778993372779,-0.054155121941607,-0.029903284362229,0.00042510774192289,0.0079714196572783,-0.00065298048144396,-0.0040981945668261,0.00067574431280471,0.0026536936548665,-0.00054748973697142,-0.0019553063002938,0.00031652522642904,0.001561591751057,-3.2936585902206e-06,-0.0012900738230584,-0.00034752362023043,0.0012872633398884],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"9c238f85-9a92-4dd3-cdf4-7247f041e224\",\"doc\":null,\"tags\":[]}},{\"id\":\"c3235607-3964-4d5b-cd91-990ba11ba7d3\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"c3235607-3964-4d5b-cd91-990ba11ba7d3\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"bba3dbfc-b056-41ce-c1f0-ccdcfa933979\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"bba3dbfc-b056-41ce-c1f0-ccdcfa933979\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"cf9a1998-bd72-4233-c264-64b58a1ea865\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Line\",\"id\":\"bba3dbfc-b056-41ce-c1f0-ccdcfa933979\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"9c238f85-9a92-4dd3-cdf4-7247f041e224\"},\"glyph\":{\"type\":\"Line\",\"id\":\"c3235607-3964-4d5b-cd91-990ba11ba7d3\"},\"selection_glyph\":null,\"id\":\"cf9a1998-bd72-4233-c264-64b58a1ea865\",\"tags\":[]}},{\"id\":\"6bdc5456-5054-4820-c896-0bda603d1aa3\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"9c238f85-9a92-4dd3-cdf4-7247f041e224\"}}],\"id\":\"6bdc5456-5054-4820-c896-0bda603d1aa3\",\"tags\":[],\"doc\":null}},{\"id\":\"253666db-35a1-4a2a-ca06-081bfb1ffcf9\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"9c238f85-9a92-4dd3-cdf4-7247f041e224\"}}],\"id\":\"253666db-35a1-4a2a-ca06-081bfb1ffcf9\",\"tags\":[],\"doc\":null}},{\"id\":\"132547f9-471b-4e67-cec2-103187494a64\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"132547f9-471b-4e67-cec2-103187494a64\",\"geometries\":[],\"doc\":null}},{\"id\":\"b7fefa12-fb3a-4be1-cbdb-f623be640eba\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"b7fefa12-fb3a-4be1-cbdb-f623be640eba\",\"tags\":[],\"doc\":null}},{\"id\":\"19bf6371-4bcf-41c4-c1db-9581a31a9e58\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"19bf6371-4bcf-41c4-c1db-9581a31a9e58\",\"tags\":[],\"doc\":null}},{\"id\":\"57556a59-8d49-4fef-cf00-98cf84c1829f\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"b7fefa12-fb3a-4be1-cbdb-f623be640eba\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"19bf6371-4bcf-41c4-c1db-9581a31a9e58\"},\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"57556a59-8d49-4fef-cf00-98cf84c1829f\",\"doc\":null,\"tags\":[]}},{\"id\":\"e681f55b-6433-4b08-cbd5-56851e1ca9b4\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"19bf6371-4bcf-41c4-c1db-9581a31a9e58\"},\"id\":\"e681f55b-6433-4b08-cbd5-56851e1ca9b4\",\"doc\":null,\"tags\":[]}},{\"id\":\"39df18c0-5500-4893-c8f6-7f0d8b823929\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"39df18c0-5500-4893-c8f6-7f0d8b823929\",\"tags\":[],\"doc\":null}},{\"id\":\"e200bde2-7ff2-40dd-c0d6-252146e7b23e\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"e200bde2-7ff2-40dd-c0d6-252146e7b23e\",\"tags\":[],\"doc\":null}},{\"id\":\"2b5dbcd7-364b-4ba2-cb98-a6fc35ee4632\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"39df18c0-5500-4893-c8f6-7f0d8b823929\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"e200bde2-7ff2-40dd-c0d6-252146e7b23e\"},\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"2b5dbcd7-364b-4ba2-cb98-a6fc35ee4632\",\"doc\":null,\"tags\":[]}},{\"id\":\"e13a1f18-c2a2-427e-c298-97d44fbc8d35\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"e200bde2-7ff2-40dd-c0d6-252146e7b23e\"},\"id\":\"e13a1f18-c2a2-427e-c298-97d44fbc8d35\",\"doc\":null,\"tags\":[]}},{\"id\":\"3dc4d9c7-4686-4505-c5c0-94ae2d145c2c\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"3dc4d9c7-4686-4505-c5c0-94ae2d145c2c\",\"doc\":null,\"tags\":[]}},{\"id\":\"bc0cbae7-ae13-41e4-c125-fc822e16a164\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"bc0cbae7-ae13-41e4-c125-fc822e16a164\",\"doc\":null,\"tags\":[]}},{\"id\":\"9614dfa8-9f73-4906-c9b8-ce004b16bcd7\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"9614dfa8-9f73-4906-c9b8-ce004b16bcd7\",\"tags\":[],\"doc\":null}},{\"id\":\"7ef987d6-b99b-4c16-cc7e-9c4c50cb5cc4\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"7ef987d6-b99b-4c16-cc7e-9c4c50cb5cc4\",\"tags\":[],\"doc\":null}},{\"id\":\"6dab06e5-b677-4483-c434-491c70e78b59\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"6dab06e5-b677-4483-c434-491c70e78b59\",\"tags\":[],\"doc\":null}},{\"id\":\"9749a434-9fdf-409b-c008-777ce997c7b1\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"9749a434-9fdf-409b-c008-777ce997c7b1\",\"tags\":[],\"doc\":null}},{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"6bdc5456-5054-4820-c896-0bda603d1aa3\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"132547f9-471b-4e67-cec2-103187494a64\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"57556a59-8d49-4fef-cf00-98cf84c1829f\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"cf9a1998-bd72-4233-c264-64b58a1ea865\"},{\"type\":\"LinearAxis\",\"id\":\"57556a59-8d49-4fef-cf00-98cf84c1829f\"},{\"type\":\"Grid\",\"id\":\"e681f55b-6433-4b08-cbd5-56851e1ca9b4\"},{\"type\":\"LinearAxis\",\"id\":\"2b5dbcd7-364b-4ba2-cb98-a6fc35ee4632\"},{\"type\":\"Grid\",\"id\":\"e13a1f18-c2a2-427e-c298-97d44fbc8d35\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"3dc4d9c7-4686-4505-c5c0-94ae2d145c2c\"},{\"type\":\"WheelZoomTool\",\"id\":\"bc0cbae7-ae13-41e4-c125-fc822e16a164\"},{\"type\":\"BoxZoomTool\",\"id\":\"9614dfa8-9f73-4906-c9b8-ce004b16bcd7\"},{\"type\":\"PreviewSaveTool\",\"id\":\"7ef987d6-b99b-4c16-cc7e-9c4c50cb5cc4\"},{\"type\":\"ResizeTool\",\"id\":\"6dab06e5-b677-4483-c434-491c70e78b59\"},{\"type\":\"ResetTool\",\"id\":\"9749a434-9fdf-409b-c008-777ce997c7b1\"}],\"doc\":null,\"right\":[],\"title\":\"Predicted model m_est\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"2b5dbcd7-364b-4ba2-cb98-a6fc35ee4632\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"253666db-35a1-4a2a-ca06-081bfb1ffcf9\"},\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "  Bokeh.load_models(all_models);\n",
       "  var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "  $(\"#c3e914dd-9ef0-4d30-cdc5-0950b2e84f97\").html(''); // clear any previous plot in window_id\n",
       "  var view = new model.default_view({model: model, el: \"#c3e914dd-9ef0-4d30-cdc5-0950b2e84f97\"});\n",
       "    } else {\n",
       "  load_lib(bokehjs_url, function() {\n",
       "      console.log(\"Bokeh: BokehJS plotting callback run at\", new Date())\n",
       "      var modelid = \"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\";\n",
       "      var modeltype = \"Plot\";\n",
       "      var all_models = [{\"id\":\"9c238f85-9a92-4dd3-cdf4-7247f041e224\",\"type\":\"ColumnDataSource\",\"attributes\":{\"data\":{\"y\":[0.0036381575340517,-0.0039347269891247,-0.0026961404977435,0.0042212416764015,0.0038332755650542,-0.004844912923272,-0.00625966198461,0.0058701167293327,0.016652476051567,0.01579324816735,0.013022775140507,0.012284214605074,-0.0029509907129178,-0.036362401605774,-0.056922137512365,-0.038357431086277,-0.00075453023031455,0.014848645236763,0.00097055706535791,-0.011656906357337,-0.0014565661960826,0.012625520045164,0.0019674346428672,-0.01867497255127,-0.0022982252745018,0.054881822684851,0.090552476416062,0.058889929608234,-0.0019817019874752,-0.023627295354811,0.0013762547129304,0.020884398036998,-0.00066601905887153,-0.040778993372779,-0.054155121941607,-0.029903284362229,0.00042510774192289,0.0079714196572783,-0.00065298048144396,-0.0040981945668261,0.00067574431280471,0.0026536936548665,-0.00054748973697142,-0.0019553063002938,0.00031652522642904,0.001561591751057,-3.2936585902206e-06,-0.0012900738230584,-0.00034752362023043,0.0012872633398884],\"x\":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]},\"column_names\":[\"y\",\"x\"],\"cont_ranges\":{},\"discrete_ranges\":{},\"selected\":[],\"id\":\"9c238f85-9a92-4dd3-cdf4-7247f041e224\",\"doc\":null,\"tags\":[]}},{\"id\":\"c3235607-3964-4d5b-cd91-990ba11ba7d3\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"c3235607-3964-4d5b-cd91-990ba11ba7d3\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"bba3dbfc-b056-41ce-c1f0-ccdcfa933979\",\"type\":\"Line\",\"attributes\":{\"fill_alpha\":{\"units\":\"data\",\"value\":0.2},\"line_alpha\":{\"units\":\"data\",\"value\":1},\"doc\":null,\"size\":{\"units\":\"screen\",\"value\":10},\"fill_color\":{\"value\":\"red\"},\"line_color\":{\"value\":\"red\"},\"x\":{\"units\":\"data\",\"field\":\"x\"},\"id\":\"bba3dbfc-b056-41ce-c1f0-ccdcfa933979\",\"y\":{\"units\":\"data\",\"field\":\"y\"},\"tags\":[]}},{\"id\":\"cf9a1998-bd72-4233-c264-64b58a1ea865\",\"type\":\"GlyphRenderer\",\"attributes\":{\"name\":null,\"nonselection_glyph\":{\"type\":\"Line\",\"id\":\"bba3dbfc-b056-41ce-c1f0-ccdcfa933979\"},\"doc\":null,\"server_data_source\":null,\"data_source\":{\"type\":\"ColumnDataSource\",\"id\":\"9c238f85-9a92-4dd3-cdf4-7247f041e224\"},\"glyph\":{\"type\":\"Line\",\"id\":\"c3235607-3964-4d5b-cd91-990ba11ba7d3\"},\"selection_glyph\":null,\"id\":\"cf9a1998-bd72-4233-c264-64b58a1ea865\",\"tags\":[]}},{\"id\":\"6bdc5456-5054-4820-c896-0bda603d1aa3\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"x\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"9c238f85-9a92-4dd3-cdf4-7247f041e224\"}}],\"id\":\"6bdc5456-5054-4820-c896-0bda603d1aa3\",\"tags\":[],\"doc\":null}},{\"id\":\"253666db-35a1-4a2a-ca06-081bfb1ffcf9\",\"type\":\"DataRange1d\",\"attributes\":{\"sources\":[{\"columns\":[\"y\"],\"source\":{\"type\":\"ColumnDataSource\",\"id\":\"9c238f85-9a92-4dd3-cdf4-7247f041e224\"}}],\"id\":\"253666db-35a1-4a2a-ca06-081bfb1ffcf9\",\"tags\":[],\"doc\":null}},{\"id\":\"132547f9-471b-4e67-cec2-103187494a64\",\"type\":\"ToolEvents\",\"attributes\":{\"tags\":[],\"id\":\"132547f9-471b-4e67-cec2-103187494a64\",\"geometries\":[],\"doc\":null}},{\"id\":\"b7fefa12-fb3a-4be1-cbdb-f623be640eba\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"b7fefa12-fb3a-4be1-cbdb-f623be640eba\",\"tags\":[],\"doc\":null}},{\"id\":\"19bf6371-4bcf-41c4-c1db-9581a31a9e58\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"19bf6371-4bcf-41c4-c1db-9581a31a9e58\",\"tags\":[],\"doc\":null}},{\"id\":\"57556a59-8d49-4fef-cf00-98cf84c1829f\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"b7fefa12-fb3a-4be1-cbdb-f623be640eba\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"19bf6371-4bcf-41c4-c1db-9581a31a9e58\"},\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"57556a59-8d49-4fef-cf00-98cf84c1829f\",\"doc\":null,\"tags\":[]}},{\"id\":\"e681f55b-6433-4b08-cbd5-56851e1ca9b4\",\"type\":\"Grid\",\"attributes\":{\"dimension\":0,\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"19bf6371-4bcf-41c4-c1db-9581a31a9e58\"},\"id\":\"e681f55b-6433-4b08-cbd5-56851e1ca9b4\",\"doc\":null,\"tags\":[]}},{\"id\":\"39df18c0-5500-4893-c8f6-7f0d8b823929\",\"type\":\"BasicTickFormatter\",\"attributes\":{\"id\":\"39df18c0-5500-4893-c8f6-7f0d8b823929\",\"tags\":[],\"doc\":null}},{\"id\":\"e200bde2-7ff2-40dd-c0d6-252146e7b23e\",\"type\":\"BasicTicker\",\"attributes\":{\"num_minor_ticks\":5,\"id\":\"e200bde2-7ff2-40dd-c0d6-252146e7b23e\",\"tags\":[],\"doc\":null}},{\"id\":\"2b5dbcd7-364b-4ba2-cb98-a6fc35ee4632\",\"type\":\"LinearAxis\",\"attributes\":{\"formatter\":{\"type\":\"BasicTickFormatter\",\"id\":\"39df18c0-5500-4893-c8f6-7f0d8b823929\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"e200bde2-7ff2-40dd-c0d6-252146e7b23e\"},\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"axis_label\":null,\"id\":\"2b5dbcd7-364b-4ba2-cb98-a6fc35ee4632\",\"doc\":null,\"tags\":[]}},{\"id\":\"e13a1f18-c2a2-427e-c298-97d44fbc8d35\",\"type\":\"Grid\",\"attributes\":{\"dimension\":1,\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"ticker\":{\"type\":\"BasicTicker\",\"id\":\"e200bde2-7ff2-40dd-c0d6-252146e7b23e\"},\"id\":\"e13a1f18-c2a2-427e-c298-97d44fbc8d35\",\"doc\":null,\"tags\":[]}},{\"id\":\"3dc4d9c7-4686-4505-c5c0-94ae2d145c2c\",\"type\":\"PanTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"3dc4d9c7-4686-4505-c5c0-94ae2d145c2c\",\"doc\":null,\"tags\":[]}},{\"id\":\"bc0cbae7-ae13-41e4-c125-fc822e16a164\",\"type\":\"WheelZoomTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"dimensions\":[\"width\",\"height\"],\"id\":\"bc0cbae7-ae13-41e4-c125-fc822e16a164\",\"doc\":null,\"tags\":[]}},{\"id\":\"9614dfa8-9f73-4906-c9b8-ce004b16bcd7\",\"type\":\"BoxZoomTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"9614dfa8-9f73-4906-c9b8-ce004b16bcd7\",\"tags\":[],\"doc\":null}},{\"id\":\"7ef987d6-b99b-4c16-cc7e-9c4c50cb5cc4\",\"type\":\"PreviewSaveTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"7ef987d6-b99b-4c16-cc7e-9c4c50cb5cc4\",\"tags\":[],\"doc\":null}},{\"id\":\"6dab06e5-b677-4483-c434-491c70e78b59\",\"type\":\"ResizeTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"6dab06e5-b677-4483-c434-491c70e78b59\",\"tags\":[],\"doc\":null}},{\"id\":\"9749a434-9fdf-409b-c008-777ce997c7b1\",\"type\":\"ResetTool\",\"attributes\":{\"plot\":{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"subtype\":\"Figure\"},\"id\":\"9749a434-9fdf-409b-c008-777ce997c7b1\",\"tags\":[],\"doc\":null}},{\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"type\":\"Plot\",\"attributes\":{\"x_range\":{\"type\":\"DataRange1d\",\"id\":\"6bdc5456-5054-4820-c896-0bda603d1aa3\"},\"tool_events\":{\"type\":\"ToolEvents\",\"id\":\"132547f9-471b-4e67-cec2-103187494a64\"},\"below\":[{\"type\":\"LinearAxis\",\"id\":\"57556a59-8d49-4fef-cf00-98cf84c1829f\"}],\"renderers\":[{\"type\":\"GlyphRenderer\",\"id\":\"cf9a1998-bd72-4233-c264-64b58a1ea865\"},{\"type\":\"LinearAxis\",\"id\":\"57556a59-8d49-4fef-cf00-98cf84c1829f\"},{\"type\":\"Grid\",\"id\":\"e681f55b-6433-4b08-cbd5-56851e1ca9b4\"},{\"type\":\"LinearAxis\",\"id\":\"2b5dbcd7-364b-4ba2-cb98-a6fc35ee4632\"},{\"type\":\"Grid\",\"id\":\"e13a1f18-c2a2-427e-c298-97d44fbc8d35\"}],\"above\":[],\"tools\":[{\"type\":\"PanTool\",\"id\":\"3dc4d9c7-4686-4505-c5c0-94ae2d145c2c\"},{\"type\":\"WheelZoomTool\",\"id\":\"bc0cbae7-ae13-41e4-c125-fc822e16a164\"},{\"type\":\"BoxZoomTool\",\"id\":\"9614dfa8-9f73-4906-c9b8-ce004b16bcd7\"},{\"type\":\"PreviewSaveTool\",\"id\":\"7ef987d6-b99b-4c16-cc7e-9c4c50cb5cc4\"},{\"type\":\"ResizeTool\",\"id\":\"6dab06e5-b677-4483-c434-491c70e78b59\"},{\"type\":\"ResetTool\",\"id\":\"9749a434-9fdf-409b-c008-777ce997c7b1\"}],\"doc\":null,\"right\":[],\"title\":\"Predicted model m_est\",\"extra_x_ranges\":{},\"left\":[{\"type\":\"LinearAxis\",\"id\":\"2b5dbcd7-364b-4ba2-cb98-a6fc35ee4632\"}],\"y_range\":{\"type\":\"DataRange1d\",\"id\":\"253666db-35a1-4a2a-ca06-081bfb1ffcf9\"},\"id\":\"d58eb0af-36cc-4ca7-cc91-07b7c5b4236c\",\"extra_y_ranges\":{},\"tags\":[]}}];\n",
       "      Bokeh.load_models(all_models);\n",
       "      var model = Bokeh.Collections(modeltype).get(modelid);\n",
       "      $(\"#c3e914dd-9ef0-4d30-cdc5-0950b2e84f97\").html(''); // clear any previous plot in window_id\n",
       "      var view = new model.default_view({model: model, el: \"#c3e914dd-9ef0-4d30-cdc5-0950b2e84f97\"});\n",
       "  });\n",
       "    }\n",
       "});\n",
       "</script>\n",
       "<div class=\"plotdiv\" id=\"c3e914dd-9ef0-4d30-cdc5-0950b2e84f97\"></div>\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = torch.range(1, m_est:size(1))\n",
    "plot = Plot():line(x, m_est[{{}, 1}])\n",
    "             :title('Predicted model m_est')\n",
    "             :draw()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9.978417090315e-17\t\n"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d:dist(d_pred)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is the L2 norm; Mauricio used the square of this as the misfit: "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1e-33 *\n",
       "  9.9569\n",
       "[torch.DoubleTensor of size 1x1]\n",
       "\n"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(d_pred - d):t() * (d_pred - d)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## QR factorization\n",
    "\n",
    "Again, avoiding finding inverses. Uses LAPACK.\n",
    "\n",
    "As with any QR factorization, `G` must be square."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "q, r = torch.qr(G)\n",
    "p = q:t() * d\n",
    "m_est = torch.inverse(r) * p\n",
    "d_pred = G * m_est\n",
    "\n",
    "-- Plot\n",
    "x = torch.range(1,d_pred:size(1))\n",
    "plot = Plot():circle(x, d[{{},1}], 'blue')\n",
    "             :circle(x, d_pred[{{},1}], 'red')\n",
    "             :title('blue:d   red:d_pred')\n",
    "             :draw()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "d:dist(d_pred)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "iTorch",
   "language": "lua",
   "name": "itorch"
  },
  "language_info": {
   "name": "lua",
   "version": "5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
